From f042953bdbe2a5e0d9e9e19d275fd45a958fe626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Fri, 10 Jan 2020 16:09:19 +0100 Subject: Set udup config from system properties --- src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java | 15 ++++++++++----- .../java/pl/edu/mimuw/cloudatlas/agent/modules/UDUP.java | 4 ---- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent') 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 initializeModules() throws UnknownHostException { + public static HashMap initializeModules() throws UnknownHostException, SocketException { HashMap modules = new HashMap(); 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 -- cgit v1.2.3