Commit 456a198c authored by yannick legoc's avatar yannick legoc
Browse files

first use of cameo in NomadServer

parent 993f50aa
......@@ -6,7 +6,7 @@
<name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description>
<scm>
<connection>scm:svn:http://forge.ill.fr/svn/nomad</connection>
<connection>scm:svn:http://forge.ill.fr/svn/nomad/ill/NomadCommandSystem/trunk</connection>
</scm>
<distributionManagement>
......@@ -62,6 +62,11 @@
<artifactId>protobuf-java</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>cameo-api-java</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -25,6 +25,9 @@ import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.ConnectionTimeout;
import fr.ill.ics.cameo.Server;
import fr.ill.ics.util.ConfigManager;
/**
......@@ -85,33 +88,24 @@ public class ServerDisconnected extends ServerConnectionState {
}
}
// Launch script
System.out.println("starting nomad server with nappli");
// connect to the server
Server server = new Server("tcp://localhost:7000");
// start nomad server
try {
String execCommand = getExecCommand();
System.out.println("starting " + execCommand);
// adding -remote option to avoid having console
if (serverId.equals("real") && ConfigManager.getInstance().getBoolean("serverTestMode")) {
// execution in xterm
Runtime.getRuntime().exec("xterm -bg white -fg black -e " + execCommand);
} else {
// hidden execution
Process process = Runtime.getRuntime().exec(execCommand);
// reading process output stream (flush the buffer to avoid to block the process when the buffer is full)
StreamThread readOutThread = new StreamThread(process.getInputStream());
readOutThread.start();
// reading process error stream (flush the buffer to avoid to block the process when the buffer is full)
StreamThread readErrThread = new StreamThread(process.getErrorStream());
readErrThread.start();
Application.Instance nomad = server.start("ns");
if (nomad.exists()) {
System.out.println("started " + nomad);
}
launchTime = System.currentTimeMillis();
} catch (IOException e) {
e.printStackTrace();
} catch (ConnectionTimeout e) {
System.err.println("timeout while starting nomad server");
}
server.terminate();
Integer value = nRestarts.get(serverId);
value++;
nRestarts.put(serverId, value);
......
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