Commit 47942b75 authored by legoc's avatar legoc
Browse files

Set synchronized to all the accessor methods: ensures that they are...

Set synchronized to all the accessor methods: ensures that they are thread-safe (e.g. requestSync is called concurrently with requestToken)
parent 73618751
......@@ -48,7 +48,7 @@ public class CommandLineAccessor {
return instances.get(serverId);
}
public void init() {
public synchronized void init() {
// Connect nomad server.
Application.Instance nomad = ServerInstance.getInstance().getApplicationInstance(serverId);
......@@ -72,13 +72,13 @@ public class CommandLineAccessor {
System.out.println("Created requester " + commandLineRequester);
}
public void reset() {
public synchronized void reset() {
// Terminate the requester.
commandLineRequester.terminate();
}
public void executeCommand(String text) {
public synchronized void executeCommand(String text) {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......@@ -100,7 +100,7 @@ public class CommandLineAccessor {
}
}
public void pauseCommands() {
public synchronized void pauseCommands() {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......@@ -121,7 +121,7 @@ public class CommandLineAccessor {
}
}
public void restartCommands() {
public synchronized void restartCommands() {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......@@ -142,7 +142,7 @@ public class CommandLineAccessor {
}
}
public void stopCommands() {
public synchronized void stopCommands() {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......@@ -163,7 +163,7 @@ public class CommandLineAccessor {
}
}
public void stopAtEndCommands() {
public synchronized void stopAtEndCommands() {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......@@ -184,7 +184,7 @@ public class CommandLineAccessor {
}
}
public boolean isStarted() {
public synchronized boolean isStarted() {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......@@ -209,7 +209,7 @@ public class CommandLineAccessor {
return false;
}
public boolean isPaused() {
public synchronized boolean isPaused() {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......@@ -234,7 +234,7 @@ public class CommandLineAccessor {
return false;
}
public void setCommandLineState(boolean state) {
public synchronized void setCommandLineState(boolean state) {
// Create the message type.
CommandLineRequest.Message type = CommandLineRequest.Message.newBuilder()
......
......@@ -71,7 +71,7 @@ public class ConditionManagerAccessor {
return instances.get(serverId);
}
public void init() {
public synchronized void init() {
// Connect nomad server.
Application.Instance nomad = ServerInstance.getInstance().getApplicationInstance(serverId);
......@@ -95,7 +95,7 @@ public class ConditionManagerAccessor {
System.out.println("Created requester " + conditionManagerRequester);
}
public void reset() {
public synchronized void reset() {
// Terminate the requester.
conditionManagerRequester.terminate();
......@@ -127,7 +127,7 @@ public class ConditionManagerAccessor {
}
}
public void verifyExpression(String expression) throws InvalidExpressionException, ConditionExistsException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void verifyExpression(String expression) throws InvalidExpressionException, ConditionExistsException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -152,7 +152,7 @@ public class ConditionManagerAccessor {
}
}
public void addAlarm(String name, String expression, String message, int activationDelay, boolean stopCommandZone, boolean on, String mailRecipients, String smsNumber) throws ConditionExistsException, InvalidExpressionException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void addAlarm(String name, String expression, String message, int activationDelay, boolean stopCommandZone, boolean on, String mailRecipients, String smsNumber) throws ConditionExistsException, InvalidExpressionException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -184,7 +184,7 @@ public class ConditionManagerAccessor {
}
}
public void addWarning(String name, String expression, String message, boolean on, String mailRecipients, String smsNumber) throws ConditionExistsException, InvalidExpressionException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void addWarning(String name, String expression, String message, boolean on, String mailRecipients, String smsNumber) throws ConditionExistsException, InvalidExpressionException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -214,7 +214,7 @@ public class ConditionManagerAccessor {
}
}
public void addWatchdog(String name, String expression, boolean on, String actions) throws ConditionExistsException, InvalidExpressionException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void addWatchdog(String name, String expression, boolean on, String actions) throws ConditionExistsException, InvalidExpressionException, NoSuchConditionException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -242,7 +242,7 @@ public class ConditionManagerAccessor {
}
}
public void removeCondition(int conditionId) throws NoSuchConditionException, UnremovableConditionException, ConditionExistsException, InvalidExpressionException, UnrenamableConditionException {
public synchronized void removeCondition(int conditionId) throws NoSuchConditionException, UnremovableConditionException, ConditionExistsException, InvalidExpressionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -267,7 +267,7 @@ public class ConditionManagerAccessor {
}
}
public void setConditionOn(int conditionId, boolean value) throws NoSuchConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void setConditionOn(int conditionId, boolean value) throws NoSuchConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -293,7 +293,7 @@ public class ConditionManagerAccessor {
}
}
public void renameCondition(int conditionId, String newName) throws NoSuchConditionException, UnrenamableConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException {
public synchronized void renameCondition(int conditionId, String newName) throws NoSuchConditionException, UnrenamableConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -319,7 +319,7 @@ public class ConditionManagerAccessor {
}
}
public void editAlarm(int conditionId, String expression, String message, int activationDelay, boolean stopCommandZone, String mailRecipients, String smsNumber) throws NoSuchConditionException, InvalidExpressionException, ConditionExistsException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void editAlarm(int conditionId, String expression, String message, int activationDelay, boolean stopCommandZone, String mailRecipients, String smsNumber) throws NoSuchConditionException, InvalidExpressionException, ConditionExistsException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -350,7 +350,7 @@ public class ConditionManagerAccessor {
}
}
public void editWarning(int conditionId, String expression, String message, String mailRecipients, String smsNumber) throws NoSuchConditionException, InvalidExpressionException, ConditionExistsException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void editWarning(int conditionId, String expression, String message, String mailRecipients, String smsNumber) throws NoSuchConditionException, InvalidExpressionException, ConditionExistsException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -379,7 +379,7 @@ public class ConditionManagerAccessor {
}
}
public void editWatchdog(int conditionId, String expression, String actions) throws NoSuchConditionException, InvalidExpressionException, ConditionExistsException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void editWatchdog(int conditionId, String expression, String actions) throws NoSuchConditionException, InvalidExpressionException, ConditionExistsException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -406,7 +406,7 @@ public class ConditionManagerAccessor {
}
}
public void editCommandZoneTermination(String message, String mailRecipients, String smsNumber) throws NoSuchConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException, UnrenamableConditionException {
public synchronized void editCommandZoneTermination(String message, String mailRecipients, String smsNumber) throws NoSuchConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -433,7 +433,7 @@ public class ConditionManagerAccessor {
}
}
public ClientConditionState getConditionState(int conditionId) throws NoSuchConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException, UnrenamableConditionException {
public synchronized ClientConditionState getConditionState(int conditionId) throws NoSuchConditionException, ConditionExistsException, InvalidExpressionException, UnremovableConditionException, UnrenamableConditionException {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......@@ -472,7 +472,7 @@ public class ConditionManagerAccessor {
return ClientConditionState.INACTIVE;
}
public String getConditionsXMLContent() {
public synchronized String getConditionsXMLContent() {
// Create the message type.
ConditionManagerRequest.Message type = ConditionManagerRequest.Message.newBuilder()
......
......@@ -63,7 +63,7 @@ public class DataAccessor {
return instances.get(serverId);
}
public void init() {
public synchronized void init() {
// Connect nomad server.
Application.Instance nomad = ServerInstance.getInstance().getApplicationInstance(serverId);
......@@ -87,7 +87,7 @@ public class DataAccessor {
System.out.println("Created requester " + databaseRequester);
}
public void reset() {
public synchronized void reset() {
// Terminate the requester.
databaseRequester.terminate();
......@@ -106,7 +106,7 @@ public class DataAccessor {
}
}
public int getInt32Value(int databaseID, int propertyID) {
public synchronized int getInt32Value(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -139,7 +139,7 @@ public class DataAccessor {
return 0;
}
public boolean setInt32Value(int databaseID, int propertyID, int value) {
public synchronized boolean setInt32Value(int databaseID, int propertyID, int value) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -173,7 +173,7 @@ public class DataAccessor {
return false;
}
public long getInt64Value(int databaseID, int propertyID) {
public synchronized long getInt64Value(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -206,7 +206,7 @@ public class DataAccessor {
return 0;
}
public boolean setInt64Value(int databaseID, int propertyID, long value) {
public synchronized boolean setInt64Value(int databaseID, int propertyID, long value) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -240,7 +240,7 @@ public class DataAccessor {
return false;
}
public float getFloat32Value(int databaseID, int propertyID) {
public synchronized float getFloat32Value(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -274,7 +274,7 @@ public class DataAccessor {
}
public boolean setFloat32Value(int databaseID, int propertyID, float value) {
public synchronized boolean setFloat32Value(int databaseID, int propertyID, float value) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -308,7 +308,7 @@ public class DataAccessor {
return false;
}
public double getFloat64Value(int databaseID, int propertyID) {
public synchronized double getFloat64Value(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -341,7 +341,7 @@ public class DataAccessor {
return 0;
}
public boolean setFloat64Value(int databaseID, int propertyID, double value) {
public synchronized boolean setFloat64Value(int databaseID, int propertyID, double value) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -375,7 +375,7 @@ public class DataAccessor {
return false;
}
public String getStringValue(int databaseID, int propertyID) {
public synchronized String getStringValue(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -408,7 +408,7 @@ public class DataAccessor {
return "";
}
public boolean setStringValue(int databaseID, int propertyID, String value) {
public synchronized boolean setStringValue(int databaseID, int propertyID, String value) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -442,7 +442,7 @@ public class DataAccessor {
return false;
}
public boolean getBooleanValue(int databaseID, int propertyID) {
public synchronized boolean getBooleanValue(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -475,7 +475,7 @@ public class DataAccessor {
return false;
}
public boolean setBooleanValue(int databaseID, int propertyID, boolean value) {
public synchronized boolean setBooleanValue(int databaseID, int propertyID, boolean value) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -511,7 +511,7 @@ public class DataAccessor {
public int getArraySize(int databaseID, int propertyID) {
public synchronized int getArraySize(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -544,7 +544,7 @@ public class DataAccessor {
return -1;
}
public int[] getInt32Array(int databaseID, int propertyID) {
public synchronized int[] getInt32Array(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -579,29 +579,29 @@ public class DataAccessor {
return null;
}
public void setInt32Array(int databaseID, int propertyID, int[] data) {
public synchronized void setInt32Array(int databaseID, int propertyID, int[] data) {
System.err.println("setInt32Array not yet implemented");
}
public long[] getInt64Array(int databaseID, int propertyID) {
public synchronized long[] getInt64Array(int databaseID, int propertyID) {
System.err.println("getInt64Array not yet implemented");
return null;
}
public void setInt64Array(int databaseID, int propertyID, long[] data) {
public synchronized void setInt64Array(int databaseID, int propertyID, long[] data) {
System.err.println("setInt64Array not yet implemented");
}
public float[] getFloat32Array(int databaseID, int propertyID) {
public synchronized float[] getFloat32Array(int databaseID, int propertyID) {
System.err.println("getFloat32Array not yet implemented");
return null;
}
public void setFloat32Array(int databaseID, int propertyID, float[] data) {
public synchronized void setFloat32Array(int databaseID, int propertyID, float[] data) {
System.err.println("setFloat32Array not yet implemented");
}
public double[] getFloat64Array(int databaseID, int propertyID) {
public synchronized double[] getFloat64Array(int databaseID, int propertyID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -637,11 +637,11 @@ public class DataAccessor {
return null;
}
public void setFloat64Array(int databaseID, int propertyID, double[] data) {
public synchronized void setFloat64Array(int databaseID, int propertyID, double[] data) {
System.err.println("setFloat64Array not yet implemented");
}
public ClientCommandState getCommandState(int databaseID, int commandID) {
public synchronized ClientCommandState getCommandState(int databaseID, int commandID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -700,7 +700,7 @@ public class DataAccessor {
}
public double getCommandProgression(int databaseID, int commandID) {
public synchronized double getCommandProgression(int databaseID, int commandID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -734,7 +734,7 @@ public class DataAccessor {
}
public void execute(int databaseID, int commandID) throws UnknownCommandException {
public synchronized void execute(int databaseID, int commandID) throws UnknownCommandException {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -762,7 +762,7 @@ public class DataAccessor {
}
}
public void stop(int databaseID, int commandID) {
public synchronized void stop(int databaseID, int commandID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -790,7 +790,7 @@ public class DataAccessor {
}
}
public String getWholeScannableProperties(int databaseID) {
public synchronized String getWholeScannableProperties(int databaseID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......@@ -816,7 +816,7 @@ public class DataAccessor {
return "";
}
public String getWholeDynamicProperties(int databaseID) {
public synchronized String getWholeDynamicProperties(int databaseID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
......
......@@ -94,7 +94,7 @@ public class ServantManagerAccessor {
return instances.get(serverId);
}
public void init() {
public synchronized void init() {
// Connect nomad server.
Application.Instance nomad = ServerInstance.getInstance().getApplicationInstance(serverId);
......@@ -119,7 +119,7 @@ public class ServantManagerAccessor {
}
public void reset() {
public synchronized void reset() {
// Terminate the requester.
servantManagerRequester.terminate();
......@@ -351,14 +351,14 @@ public class ServantManagerAccessor {
return "";
}
public void loadWholeConfiguration() throws LoadConfigurationFailure {
public synchronized void loadWholeConfiguration() throws LoadConfigurationFailure {
ServantData servantData = getWholeConfiguration(DATABASE_ID);
initAllMaps(servantData);
}
public void updateWholeConfiguration() throws LoadConfigurationFailure {
public synchronized void updateWholeConfiguration() throws LoadConfigurationFailure {
ServantDataUpdate servantDataUpdate = getWholeConfigurationUpdate(DATABASE_ID);
......@@ -541,7 +541,7 @@ public class ServantManagerAccessor {
}
public void addSpyProperties(int servantID) {
public synchronized void addSpyProperties(int servantID) {
ServantSpyProperties servantSpyProperties = getServantSpyProperties(DATABASE_ID, servantID);
......@@ -620,7 +620,7 @@ public class ServantManagerAccessor {
return "?";
}
public ControllerServant cloneController(ClientServantDescriptor descriptor) {
public synchronized ControllerServant cloneController(ClientServantDescriptor descriptor) {
ControllerServant controller = null;
......@@ -639,7 +639,7 @@ public class ServantManagerAccessor {
}
}
public void updateDynamicProperties(int servantID) {
public synchronized void updateDynamicProperties(int servantID) {
// first remove the current dynamic descriptors
PropertyDatabase.getInstance().removeDynamicPropertyDescriptors(servantID);
......@@ -690,7 +690,7 @@ public class ServantManagerAccessor {
}
public void removeController(ClientServantDescriptor descriptor) {
public synchronized void removeController(ClientServantDescriptor descriptor) {
removeController(descriptor.getId());
......@@ -698,7 +698,7 @@ public class ServantManagerAccessor {
ServantDatabase.getInstance().removeController(descriptor);
}
public void pauseSpies(boolean isPaused) {
public synchronized void pauseSpies(boolean isPaused) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -720,7 +720,7 @@ public class ServantManagerAccessor {
}
}
public TreeMap<String, LinkedHashMap<String, String>> getPropertiesForGeneric() {
public synchronized 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");
......@@ -736,7 +736,7 @@ public class ServantManagerAccessor {
return list;
}
public void reconnectDriver(int databaseID, int servantID) {
public synchronized void reconnectDriver(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -765,7 +765,7 @@ public class ServantManagerAccessor {
}
}
public String[] getResourceFilesByExtension(String extension) {
public synchronized String[] getResourceFilesByExtension(String extension) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -797,7 +797,7 @@ public class ServantManagerAccessor {
return null;
}
public byte[] readBinaryResourceFile(String resourceType, String fileName) throws ResourceNotFoundException {
public synchronized byte[] readBinaryResourceFile(String resourceType, String fileName) throws ResourceNotFoundException {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -828,7 +828,7 @@ public class ServantManagerAccessor {
throw new ResourceNotFoundException(fileName);
}
public String readResourceFile(String resourceType, String fileName) throws ResourceNotFoundException {
public synchronized String readResourceFile(String resourceType, String fileName) throws ResourceNotFoundException {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -860,7 +860,7 @@ public class ServantManagerAccessor {
}
public void writeResourceFile(String resourceType, String fileName, String content) {
public synchronized void writeResourceFile(String resourceType, String fileName, String content) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -883,7 +883,7 @@ public class ServantManagerAccessor {
}
}
public HashMap<String, String> getServantPropertiesValue(int databaseID, int servantID) {
public synchronized HashMap<String, String> getServantPropertiesValue(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -915,7 +915,7 @@ public class ServantManagerAccessor {
return null;
}
public HashMap<String, Integer> getServantCommandStates(int databaseID, int servantID) {
public synchronized HashMap<String, Integer> getServantCommandStates(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
......@@ -947,7 +947,7 @@ public class ServantManagerAccessor {
return null;
}
public HashMap<String, String> getFamilyImageKeys() {
public synchronized HashMap<String, String> getFamilyImageKeys() {