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
------
* Corrected blocking when exiting.
......
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>4.0.15</version>
<version>4.0.16</version>
<name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description>
<scm>
......
......@@ -22,11 +22,13 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.nscclient.log.LogSubscriber;
import fr.ill.ics.nscclient.notification.DataNotificationClient;
import fr.ill.ics.nscclient.notification.commandzone.CommandZoneEventClient;
import fr.ill.ics.nscclient.notification.commandzone.sync.CommandZoneSyncEventClient;
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.util.ConfigManager;
......@@ -52,7 +54,7 @@ public class ChangeManager {
DataNotificationClient.getInstance().readAndDispatch();
CommandZoneEventClient.getInstance().readAndDispatch();
CommandZoneSyncEventClient.getInstance().readAndDispatch();
if (ConfigManager.getInstance().getPlotyVersion() == 2) {
if (SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).getPlotyVersion() == 2) {
PlotyInstance.getInstance().readAndDispatch();
}
......
......@@ -81,7 +81,9 @@ public class PlotyInstance {
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 {
ploty = server.connect(PLOTY_NAME);
} catch (ConnectionTimeout e) {
......@@ -90,6 +92,7 @@ public class PlotyInstance {
}
}
else {
// Client on a different machine as server
List<Info> info = server.getApplicationInfos(PLOTY_NAME);
if (info.isEmpty() == false) {
server.killAllAndWaitFor(PLOTY_NAME);
......
......@@ -155,7 +155,7 @@ public class ServerSessionManager {
SurveySubscriberImpl.getInstance(serverId).unsubscribe();
DataChangeSubscriber.getInstance(serverId).unsubscribe();
if (serverId.equals("real")) {
if (ConfigManager.getInstance().getPlotyVersion() == 2) {
if (SessionManager.getInstance(serverId).getPlotyVersion() == 2) {
PlotyInstance.getInstance().unsubscribe();
}
}
......@@ -195,7 +195,7 @@ public class ServerSessionManager {
}
if (serverId.equals("real")) {
if (ConfigManager.getInstance().getPlotyVersion() == 2) {
if (SessionManager.getInstance(serverId).getPlotyVersion() == 2) {
try {
PlotyInstance.getInstance().unsubscribe();
} catch (Exception e) {
......
......@@ -42,7 +42,7 @@ public class SessionManager {
private String remoteUserName;
private String password;
private String instrumentName;
private int plotyVersion = 0;
private String user = null;
......@@ -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() {
return allOk;
}
......@@ -334,6 +354,12 @@ public class SessionManager {
return remoteUserName;
}
public int getPlotyVersion() {
if (plotyVersion == 0) {
plotyVersion = getServerPlotyVersion();
}
return plotyVersion;
}
private String getUser() {
if (user == null) {
......
......@@ -620,13 +620,13 @@ public class ConfigManager {
return false;
}
public int getPlotyVersion() {
String value = getStringOrNothingAtAll("plotyVersion");
if (value != null) {
return Integer.valueOf(value.trim());
}
return 1;
}
// public int getPlotyVersion() {
// String value = getStringOrNothingAtAll("plotyVersion");
// if (value != null) {
// return Integer.valueOf(value.trim());
// }
// return 1;
// }
public boolean isRemoteClient() {
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