diff options
Diffstat (limited to 'same/src')
4 files changed, 10 insertions, 12 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientApp.java b/same/src/main/java/com/orbekk/same/ClientApp.java index 499e8ef..bc873fa 100644 --- a/same/src/main/java/com/orbekk/same/ClientApp.java +++ b/same/src/main/java/com/orbekk/same/ClientApp.java @@ -54,7 +54,7 @@ public class ClientApp { public void run(int port, String networkName, String masterUrl) { - SameController controller = SameController.create(port); + SameController controller = SameController.create(null); try { controller.start(); } catch (Exception e) { diff --git a/same/src/main/java/com/orbekk/same/MasterApp.java b/same/src/main/java/com/orbekk/same/MasterApp.java index 7f79830..c5e270a 100644 --- a/same/src/main/java/com/orbekk/same/MasterApp.java +++ b/same/src/main/java/com/orbekk/same/MasterApp.java @@ -5,14 +5,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.googlecode.jsonrpc4j.JsonRpcServer; +import com.orbekk.same.config.Configuration; public class MasterApp { private Logger logger = LoggerFactory.getLogger(getClass()); - private Server server; - private static final int timeout = 1000; - public void run(int port) { - SameController controller = SameController.create(port); + public void run(Configuration configuration) { + SameController controller = SameController.create(configuration); try { controller.start(); } catch (Exception e) { @@ -22,11 +21,7 @@ public class MasterApp { } public static void main(String[] args) { - if (args.length < 1) { - System.err.println("Usage: port"); - System.exit(1); - } - int port = Integer.parseInt(args[0]); - (new MasterApp()).run(port); + Configuration configuration = Configuration.loadOrDie(); + (new MasterApp()).run(configuration); } } diff --git a/same/src/main/java/com/orbekk/same/SameController.java b/same/src/main/java/com/orbekk/same/SameController.java index 704f213..503bfba 100644 --- a/same/src/main/java/com/orbekk/same/SameController.java +++ b/same/src/main/java/com/orbekk/same/SameController.java @@ -12,6 +12,7 @@ import com.googlecode.jsonrpc4j.JsonRpcServer; import com.orbekk.net.HttpUtil; import com.orbekk.paxos.PaxosService; import com.orbekk.paxos.PaxosServiceImpl; +import com.orbekk.same.config.Configuration; import com.orbekk.same.http.RpcHandler; import com.orbekk.same.http.ServerBuilder; import com.orbekk.same.http.StateServlet; @@ -29,7 +30,8 @@ public class SameController implements UrlReceiver { */ private static final int timeout = 10000; - public static SameController create(int port) { + public static SameController create(Configuration configuration) { + int port = configuration.getInt("port"); ConnectionManagerImpl connections = new ConnectionManagerImpl( timeout, timeout); State state = new State("Default"); diff --git a/same/src/main/resources/master.properties.example b/same/src/main/resources/master.properties.example new file mode 100644 index 0000000..338d6a9 --- /dev/null +++ b/same/src/main/resources/master.properties.example @@ -0,0 +1 @@ +port=10010 |