From ac7aa67be63bea11246b5d39d1ff2bd7d16d2a1c Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 24 Nov 2019 22:09:41 +0100 Subject: Pass registry address to fetcher (#41) --- .../pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/fetcher') diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java b/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java index 1d4a2ce..7583c14 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java @@ -15,6 +15,9 @@ import com.google.gson.Gson; import pl.edu.mimuw.cloudatlas.model.*; public class Fetcher { + private static String host; + private static int port; + private static final List fetcherAttributeNames = Arrays.asList( "avg_load", "free_disk", @@ -71,7 +74,7 @@ public class Fetcher { } private static void initializeApiStub() throws RemoteException, NotBoundException { - Registry registry = LocateRegistry.getRegistry("localhost"); + Registry registry = LocateRegistry.getRegistry(host, port); api = (Api) registry.lookup("Api"); System.out.println("Fetcher runs with registry"); } @@ -124,7 +127,23 @@ public class Fetcher { } } + private static void parseArgs(String[] args) { + System.out.println("args length: " + args.length); + if (args.length < 2) { + port = 1099; + } else { + port = Integer.parseInt(args[1]); + } + + if (args.length < 1) { + host = "localhost"; + } else { + host = args[0]; + } + } + public static void main(String[] args) { + parseArgs(args); fetchData(); } } -- cgit v1.2.3