Commit ce1a7be6 authored by hengwen's avatar hengwen
Browse files

Adapt to docker environment

parent d69c9cfd
Pipeline #96589 failed with stages
in 22 seconds
......@@ -21,12 +21,13 @@
package rwth.rmi.model.server;
import org.I0Itec.zkclient.ZkClient;
import org.apache.zookeeper.ZooKeeper;
import java.io.File;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.UnknownHostException;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
......@@ -38,7 +39,7 @@ public class RMIServer {
public final static String MODEL_MANAGER = "ModelManager";
public final static String ZK_NODE = "/rmi-servers/all";
public static void main(String[] args) {
public static void main(String[] args) throws UnknownHostException {
if (args.length < 2){
System.out.println("Please assign a port that the RMI server need to bind, also the path to AutopilotAdapter.dll");
return;
......@@ -55,17 +56,22 @@ public class RMIServer {
return;
}
ZkClient zk = new ZkClient("localhost:2181", 1000, 5000);
String zoo_servers;
zoo_servers = System.getenv("ZOO_SERVERS");
if (zoo_servers == null){
zoo_servers = "localhost:2181";
}
ZkClient zk = new ZkClient(zoo_servers, 1000, 5000);
ModelManager manager = new ModelManager(args[1]);
String host = "localhost";
String host = InetAddress.getLocalHost().getHostName();
int port = Integer.valueOf(args[0]);
try {
Registry registry = LocateRegistry.createRegistry(port);
System.out.println("RMIRegistry serving on port: " + port);
//bind the ModelManager to a stub, representing the remote object
registry.bind(MODEL_MANAGER, UnicastRemoteObject.exportObject(manager, 0));
registry.bind(MODEL_MANAGER, UnicastRemoteObject.exportObject(manager, port));
register(zk, host, port);
System.out.println("RMIManager listening");
......
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