From ad872a25f94f6297a659cf945c4e1547ed8f28d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Fri, 10 Jan 2020 16:29:49 +0100 Subject: Fix getting system properties --- build.gradle | 8 ++++++++ src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index a18999c..de9a9df 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,10 @@ ext.freshnessPeriod = { return System.getProperty("freshnessPeriod") ?: 60 * 1000 } +ext.UDUPHostname = { + return System.getProperty("hostname") ?: "localhost" +} + ext.port = { return System.getProperty("port") ?: 5999; } @@ -73,6 +77,10 @@ task runAgent(type: JavaExec) { main = 'pl.edu.mimuw.cloudatlas.agent.Agent' systemProperty 'java.rmi.server.hostname', hostname() systemProperty 'freshness_period', freshnessPeriod() + systemProperty 'UDUPServer.hostname', UDUPHostname() + systemProperty 'UDUPServer.port', port() + systemProperty 'UDUPServer.timeout', port() + systemProperty 'UDUPServer.bufsize', port() } task runClient(type: JavaExec) { 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 a178193..62cd544 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java @@ -40,17 +40,17 @@ public class Agent { } } - public static HashMap initializeModules() throws UnknownHostException, SocketException { + public static HashMap initializeModules() throws UnknownHostException, SocketException, NullPointerException { HashMap modules = new HashMap(); modules.put(ModuleType.TIMER_SCHEDULER, new TimerScheduler(ModuleType.TIMER_SCHEDULER)); modules.put(ModuleType.RMI, new Remik()); - Long freshnessPeriod = Long.getLong(System.getProperty("freshness_period")); + Long freshnessPeriod = Long.getLong("freshness_period"); modules.put(ModuleType.STATE, new Stanik(freshnessPeriod)); modules.put(ModuleType.QUERY, new Qurnik()); - Integer port = Integer.getInteger(System.getProperty("port")); - Integer timeout = Integer.getInteger(System.getProperty("timeout")); - Integer bufsize = Integer.getInteger(System.getProperty("bufsize")); + Integer port = Integer.getInteger("UDUPServer.port"); + Integer timeout = Integer.getInteger("UDUPServer.timeout"); + Integer bufsize = Integer.getInteger("UDUPServer.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 -- cgit v1.2.3