m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle12
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java15
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUP.java4
3 files changed, 22 insertions, 9 deletions
diff --git a/build.gradle b/build.gradle
index 01e8685..a18999c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,6 +22,18 @@ ext.freshnessPeriod = {
return System.getProperty("freshnessPeriod") ?: 60 * 1000
}
+ext.port = {
+ return System.getProperty("port") ?: 5999;
+}
+
+ext.timeout = {
+ return System.getProperty("timeout") ?: 5000;
+}
+
+ext.bufsize = {
+ return System.getProperty("bufsize") ?: 512;
+}
+
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java
index ad2a650..a178193 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java
@@ -2,6 +2,7 @@ package pl.edu.mimuw.cloudatlas.agent;
import java.net.Inet4Address;
import java.net.InetAddress;
+import java.net.SocketException;
import java.net.UnknownHostException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
@@ -39,15 +40,19 @@ public class Agent {
}
}
- public static HashMap<ModuleType, Module> initializeModules() throws UnknownHostException {
+ public static HashMap<ModuleType, Module> initializeModules() throws UnknownHostException, SocketException {
HashMap<ModuleType, Module> modules = new HashMap<ModuleType, Module>();
modules.put(ModuleType.TIMER_SCHEDULER, new TimerScheduler(ModuleType.TIMER_SCHEDULER));
modules.put(ModuleType.RMI, new Remik());
- Long freshnessPeriod = new Long(System.getProperty("freshness_period"));
+ Long freshnessPeriod = Long.getLong(System.getProperty("freshness_period"));
modules.put(ModuleType.STATE, new Stanik(freshnessPeriod));
modules.put(ModuleType.QUERY, new Qurnik());
- UDUPServer server = new UDUPServer(InetAddress.getByName("127.0.0.1"), 5988, 2000);
- modules.put(ModuleType.UDP, new UDUP(5988, 5000, 20000, null));
+
+ Integer port = Integer.getInteger(System.getProperty("port"));
+ Integer timeout = Integer.getInteger(System.getProperty("timeout"));
+ Integer bufsize = Integer.getInteger(System.getProperty("bufsize"));
+ UDUPServer server = new UDUPServer(InetAddress.getByName("127.0.0.1"), port, bufsize);
+ modules.put(ModuleType.UDP, new UDUP(port, timeout, bufsize, server));
// TODO add modules as we implement them
return modules;
}
@@ -90,7 +95,7 @@ public class Agent {
try {
modules = initializeModules();
- } catch (UnknownHostException e) {
+ } catch (UnknownHostException | SocketException e) {
System.out.println("Module initialization failed");
e.printStackTrace();
return;
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUP.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUP.java
index 341d947..e2243e1 100644
--- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUP.java
+++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/UDUP.java
@@ -23,10 +23,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
* due to ValueContact design
*/
-// TODO set server port in global config - must be the same everywhere
-// TODO same with buffer size
-
-// TODO separate server like newapiimpl
// TODO add timestamps as close to sending as possible
// TODO wysylac tylko remotegossipgirl message