diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-03 17:11:15 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-03 17:11:15 +0100 |
commit | da62794fcd08be055518af888c782a2c56834d54 (patch) | |
tree | 84570b2f9d2b32b3f4018f0a48ee0306989a0d9d /same/src/main/java/com | |
parent | 3f0132826854d18c9ca49ab7ff5d9eb5fa11b0e4 (diff) |
Use Configuration in MasterApp.
Breaks ClientApp.
Diffstat (limited to 'same/src/main/java/com')
-rw-r--r-- | same/src/main/java/com/orbekk/same/ClientApp.java | 2 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/MasterApp.java | 15 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/SameController.java | 4 |
3 files changed, 9 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"); |