Commit 22b98729 authored by Locatelli's avatar Locatelli
Browse files

Add get ploty version from server

parent 331ef8e4
4.0.16 09/06/2020
------
* Get ploty version from nomad server.
4.0.15 05/06/2020 4.0.15 05/06/2020
------ ------
* Corrected blocking when exiting. * Corrected blocking when exiting.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId> <groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId> <artifactId>nomadcommandsystem</artifactId>
<version>4.0.15</version> <version>4.0.16</version>
<name>NomadCommandSystem</name> <name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description> <description>Java bridge for the communication with the Nomad server</description>
<scm> <scm>
......
...@@ -22,11 +22,13 @@ import java.util.Iterator; ...@@ -22,11 +22,13 @@ import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.nscclient.log.LogSubscriber; import fr.ill.ics.nscclient.log.LogSubscriber;
import fr.ill.ics.nscclient.notification.DataNotificationClient; import fr.ill.ics.nscclient.notification.DataNotificationClient;
import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient; import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient;
import fr.ill.ics.nscclient.notification.commandzone.sync.CommandZoneSyncEventClient; import fr.ill.ics.nscclient.notification.commandzone.sync.CommandZoneSyncEventClient;
import fr.ill.ics.nscclient.ploty.PlotyInstance; import fr.ill.ics.nscclient.ploty.PlotyInstance;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
import fr.ill.ics.nscclient.survey.SurveySubscriberImpl; import fr.ill.ics.nscclient.survey.SurveySubscriberImpl;
import fr.ill.ics.util.ConfigManager; import fr.ill.ics.util.ConfigManager;
...@@ -52,7 +54,7 @@ public class ChangeManager { ...@@ -52,7 +54,7 @@ public class ChangeManager {
DataNotificationClient.getInstance().readAndDispatch(); DataNotificationClient.getInstance().readAndDispatch();
CommandZoneEventClient.getInstance().readAndDispatch(); CommandZoneEventClient.getInstance().readAndDispatch();
CommandZoneSyncEventClient.getInstance().readAndDispatch(); CommandZoneSyncEventClient.getInstance().readAndDispatch();
if (ConfigManager.getInstance().getPlotyVersion() == 2) { if (SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).getPlotyVersion() == 2) {
PlotyInstance.getInstance().readAndDispatch(); PlotyInstance.getInstance().readAndDispatch();
} }
......
...@@ -81,7 +81,9 @@ public class PlotyInstance { ...@@ -81,7 +81,9 @@ public class PlotyInstance {
Application.Instance ploty = null; Application.Instance ploty = null;
if (ConfigManager.getInstance().getString(ConfigManager.CLIENT_TYPE_PROPERTY).contains("main")) { String nomadServerEndpoint = ConfigManager.getInstance().getNomadServerEndpoint();
if (serverEndpoint.contentEquals(nomadServerEndpoint)) {
// Client on a same machine as server
try { try {
ploty = server.connect(PLOTY_NAME); ploty = server.connect(PLOTY_NAME);
} catch (ConnectionTimeout e) { } catch (ConnectionTimeout e) {
...@@ -90,6 +92,7 @@ public class PlotyInstance { ...@@ -90,6 +92,7 @@ public class PlotyInstance {
} }
} }
else { else {
// Client on a different machine as server
List<Info> info = server.getApplicationInfos(PLOTY_NAME); List<Info> info = server.getApplicationInfos(PLOTY_NAME);
if (info.isEmpty() == false) { if (info.isEmpty() == false) {
server.killAllAndWaitFor(PLOTY_NAME); server.killAllAndWaitFor(PLOTY_NAME);
......
...@@ -155,7 +155,7 @@ public class ServerSessionManager { ...@@ -155,7 +155,7 @@ public class ServerSessionManager {
SurveySubscriberImpl.getInstance(serverId).unsubscribe(); SurveySubscriberImpl.getInstance(serverId).unsubscribe();
DataChangeSubscriber.getInstance(serverId).unsubscribe(); DataChangeSubscriber.getInstance(serverId).unsubscribe();
if (serverId.equals("real")) { if (serverId.equals("real")) {
if (ConfigManager.getInstance().getPlotyVersion() == 2) { if (SessionManager.getInstance(serverId).getPlotyVersion() == 2) {
PlotyInstance.getInstance().unsubscribe(); PlotyInstance.getInstance().unsubscribe();
} }
} }
...@@ -195,7 +195,7 @@ public class ServerSessionManager { ...@@ -195,7 +195,7 @@ public class ServerSessionManager {
} }
if (serverId.equals("real")) { if (serverId.equals("real")) {
if (ConfigManager.getInstance().getPlotyVersion() == 2) { if (SessionManager.getInstance(serverId).getPlotyVersion() == 2) {
try { try {
PlotyInstance.getInstance().unsubscribe(); PlotyInstance.getInstance().unsubscribe();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -42,7 +42,7 @@ public class SessionManager { ...@@ -42,7 +42,7 @@ public class SessionManager {
private String remoteUserName; private String remoteUserName;
private String password; private String password;
private String instrumentName; private String instrumentName;
private int plotyVersion = 0;
private String user = null; private String user = null;
...@@ -310,6 +310,26 @@ public class SessionManager { ...@@ -310,6 +310,26 @@ public class SessionManager {
} }
} }
public synchronized int getServerPlotyVersion() {
// Create the message type.
SessionRequests.Message type = SessionRequests.Message.newBuilder()
.setType(SessionRequests.Message.Type.PlotyVersion)
.build();
sessionRequester.send(type.toByteArray());
int version = 0;
try {
version = Common.Int32Response.parseFrom(sessionRequester.receive()).getValue();
}
catch (InvalidProtocolBufferException e) {
System.err.println("error in parsing response of getPlotyVersion");
}
return version;
}
public boolean isOk() { public boolean isOk() {
return allOk; return allOk;
} }
...@@ -334,6 +354,12 @@ public class SessionManager { ...@@ -334,6 +354,12 @@ public class SessionManager {
return remoteUserName; return remoteUserName;
} }
public int getPlotyVersion() {
if (plotyVersion == 0) {
plotyVersion = getServerPlotyVersion();
}
return plotyVersion;
}
private String getUser() { private String getUser() {
if (user == null) { if (user == null) {
......
...@@ -620,13 +620,13 @@ public class ConfigManager { ...@@ -620,13 +620,13 @@ public class ConfigManager {
return false; return false;
} }
public int getPlotyVersion() { // public int getPlotyVersion() {
String value = getStringOrNothingAtAll("plotyVersion"); // String value = getStringOrNothingAtAll("plotyVersion");
if (value != null) { // if (value != null) {
return Integer.valueOf(value.trim()); // return Integer.valueOf(value.trim());
} // }
return 1; // return 1;
} // }
public boolean isRemoteClient() { public boolean isRemoteClient() {
return remoteClient; return remoteClient;
......
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