Commit a3350ce9 authored by ics's avatar ics
Browse files

Merge branch V3.1_182 into master

parent 1a981228
......@@ -2031,7 +2031,7 @@ public class CommandZoneAccessor {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
.setType(CommandZoneRequests.Message.Type.GetCurrentValue)
.setType(CommandZoneRequests.Message.Type.GetType)
.build();
// Create the request.
......
......@@ -63,15 +63,15 @@ public class PortableByteArray {
int result;
if (endianness == Endianess.BIG) {
result = (int)(encodedData[pos+3] & 0xff) << 0 |
(int)(encodedData[pos+2] & 0xff) << 8 |
(int)(encodedData[pos+1] & 0xff) << 16 |
(int)(encodedData[pos+0] & 0xff) << 24;
result = (encodedData[pos+3] & 0xff) << 0 |
(encodedData[pos+2] & 0xff) << 8 |
(encodedData[pos+1] & 0xff) << 16 |
(encodedData[pos+0] & 0xff) << 24;
} else {
result = (int)(encodedData[pos+0] & 0xff) << 0 |
(int)(encodedData[pos+1] & 0xff) << 8 |
(int)(encodedData[pos+2] & 0xff) << 16 |
(int)(encodedData[pos+3] & 0xff) << 24;
result = (encodedData[pos+0] & 0xff) << 0 |
(encodedData[pos+1] & 0xff) << 8 |
(encodedData[pos+2] & 0xff) << 16 |
(encodedData[pos+3] & 0xff) << 24;
}
pos = pos + 4;
......
......@@ -25,6 +25,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -717,8 +718,8 @@ public class ServantManagerAccessor {
}
}
public HashMap<String, LinkedHashMap<String, String>> getPropertiesForGeneric() {
HashMap<String, LinkedHashMap<String, String>> list = new HashMap<String, LinkedHashMap<String, String>>();
public TreeMap<String, LinkedHashMap<String, String>> getPropertiesForGeneric() {
TreeMap<String, LinkedHashMap<String, String>> list = new TreeMap<String, LinkedHashMap<String, String>>();
String buf = getPropertiesForGenericRequest();
StringTokenizer tokgen = new StringTokenizer(buf,"\n");
while(tokgen.hasMoreTokens()) {
......@@ -1002,5 +1003,28 @@ public class ServantManagerAccessor {
return null;
}
public void logUserMessage(String userName, String message) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.UserLog)
.build();
// Create the request.
ServantManagerRequest.UserLogRequest request = ServantManagerRequest.UserLogRequest.newBuilder()
.setUserName(userName)
.setMessage(message)
.build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.BooleanResponse.parseFrom(servantManagerRequester.receive());
// Nothing to return as the log should always succeed.
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "logUserMessage", "error in parsing response");
}
}
}
\ No newline at end of file
......@@ -51,7 +51,7 @@ public class CommandZoneEventClient {
}
public int hashCode() {
return (new Integer(databaseId)).hashCode() + (new Integer(commandBoxId)).hashCode();
return (Integer.valueOf(databaseId)).hashCode() + (Integer.valueOf(commandBoxId)).hashCode();
}
public boolean equals(Object key) {
......@@ -250,13 +250,12 @@ public class CommandZoneEventClient {
}
private void notifyCommandBoxPropertyChanged(CommandBoxPropertyEvent event) {
CommandZoneBoxKey key = new CommandZoneBoxKey(event.getDatabaseId(), event.getCommandBoxId());
synchronized (propertyListeners) {
if (propertyListeners.containsKey(key)) {
HashSet<ICommandBoxPropertyEventListener> listeners = propertyListeners.get(key);
HashSet<ICommandBoxPropertyEventListener> listenersorg = propertyListeners.get(key);
HashSet<ICommandBoxPropertyEventListener> listeners = new HashSet<ICommandBoxPropertyEventListener>(listenersorg);
Iterator<ICommandBoxPropertyEventListener> it = listeners.iterator();
while (it.hasNext()) {
it.next().commandBoxPropertyChanged(event.getCommandBoxId(), event.getPropertyId());
......
......@@ -36,7 +36,7 @@ import fr.ill.ics.nscclient.notification.commandzone.ServerCommandZoneEventManag
import fr.ill.ics.nscclient.servant.ConfigurationManager;
import fr.ill.ics.nscclient.servant.ConfigurationManager.LoadFailure;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager.ClientAlreadyLaunchedException;
import fr.ill.ics.nscclient.survey.SurveySubcriberImpl;
import fr.ill.ics.nscclient.survey.SurveySubscriberImpl;
public class ServerSessionManager {
......@@ -88,7 +88,7 @@ public class ServerSessionManager {
SessionManager.getInstance(serverId).login(standAlone);
}
catch (ClientAlreadyLaunchedException e) {
logoutAll(false);
// Only rethrow the exception. The call to logoutAll is made in the main application.
throw e;
}
......@@ -145,7 +145,7 @@ public class ServerSessionManager {
ServerCommandZoneEventManager.getInstance(serverId).reset();
LogSubscriber.getInstance(serverId).unsubscribe();
SurveySubcriberImpl.getInstance(serverId).unsubscribe();
SurveySubscriberImpl.getInstance(serverId).unsubscribe();
DataChangeSubscriber.getInstance(serverId).unsubscribe();
DataAccessor.getInstance(serverId).reset();
......@@ -169,7 +169,7 @@ public class ServerSessionManager {
}
try {
SurveySubcriberImpl.getInstance(serverId).unsubscribe();
SurveySubscriberImpl.getInstance(serverId).unsubscribe();
} catch (Exception e) {
System.out.println("Cannot unsubscribe survey");
}
......
......@@ -35,7 +35,7 @@ import fr.ill.ics.nscclient.serverconnection.ServerInstance;
public class SurveySubcriberImpl {
public class SurveySubscriberImpl {
private Set<ServerSurveyXMLListener> surveyXMLListeners = new LinkedHashSet<ServerSurveyXMLListener>();
private List<String> pendingXMLMessages = new ArrayList<String>();
......@@ -43,24 +43,24 @@ public class SurveySubcriberImpl {
private Application.Subscriber subscriber;
private Thread subscriberThread;
private static Map<String, SurveySubcriberImpl> instances = new HashMap<String, SurveySubcriberImpl>();
private static Map<String, SurveySubscriberImpl> instances = new HashMap<String, SurveySubscriberImpl>();
private String serverId;
private SurveySubcriberImpl(String serverId) {
private SurveySubscriberImpl(String serverId) {
this.serverId = serverId;
}
public static SurveySubcriberImpl getInstance(String serverId) {
public static SurveySubscriberImpl getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
SurveySubcriberImpl instance = new SurveySubcriberImpl(serverId);
SurveySubscriberImpl instance = new SurveySubscriberImpl(serverId);
instances.put(serverId, instance);
}
return instances.get(serverId);
}
public static Map<String, SurveySubcriberImpl> getInstances() {
public static Map<String, SurveySubscriberImpl> getInstances() {
return instances;
}
......@@ -149,21 +149,40 @@ public class SurveySubcriberImpl {
public void unsubscribe() {
System.out.println("Unsubscribing survey...");
// The subscriber can be null in case the window was not open.
if (subscriber == null) {
System.out.println("The survey subscriber is null");
return;
}
System.out.println("Unsubscribing survey with catch of the exceptions...");
// Cancel can throw a zeromq exception.
try {
// Stop the subscriber.
subscriber.cancel();
// Join the thread.
try {
subscriberThread.join();
}
catch (InterruptedException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
// Added the try catch if the exception in cancel leads to another exception in terminate.
try {
// Terminate the subscriber.
subscriber.terminate();
}
catch (Exception e) {
e.printStackTrace();
}
// Reset the subscriber.
subscriber = null;
System.out.println("Unsubscribed from the survey");
}
......
......@@ -81,6 +81,7 @@ public class ConfigManager {
public final static String X_UNCLOSEABLE_SPY = "X_UNCLOSEABLE_SPY";
public final static String Y_UNCLOSEABLE_SPY = "Y_UNCLOSEABLE_SPY";
public final static String MAGNIFY_FACTOR_INDEX = "MAGNIFY_FACTOR_INDEX";
public final static String USE_NOMADLOGS = "USE_NOMADLOGS";
public final static String X_CONDITIONS_SPY = "X_CONDITIONS_SPY";
public final static String Y_CONDITIONS_SPY = "Y_CONDITIONS_SPY";
......@@ -331,7 +332,7 @@ public class ConfigManager {
* @return the integer value that match with the propertyName in the config file
*/
public synchronized int getInt(String propertyName) {
return new Integer(properties.getProperty(propertyName)).intValue();
return Integer.valueOf(properties.getProperty(propertyName));
}
......@@ -497,7 +498,7 @@ public class ConfigManager {
if (configurationException instanceof PropertyNotFoundException) {
PropertyNotFoundException pnfe = (PropertyNotFoundException)configurationException;
if (pnfe.getControllerName().equals(controllerName)) {
if (pnfe.getControllerName() != null && pnfe.getControllerName().equals(controllerName)) {
if (set == null) {
set = new HashSet<ConfigurationException>();
}
......@@ -507,7 +508,7 @@ public class ConfigManager {
} else if (configurationException instanceof CommandNotFoundException) {
CommandNotFoundException cnfe = (CommandNotFoundException)configurationException;
if (cnfe.getControllerName().equals(controllerName)) {
if (cnfe.getControllerName() != null && cnfe.getControllerName().equals(controllerName)) {
if (set == null) {
set = new HashSet<ConfigurationException>();
}
......@@ -523,7 +524,7 @@ public class ConfigManager {
set.add(configurationException);
}
} else if (configurationException instanceof ConfigurationException) { // ControllerNotFoundException managed here
} else { // ControllerNotFoundException managed here
if (configurationException.getControllerType().equals(controllerType)) {
if (set == null) {
set = new HashSet<ConfigurationException>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment