m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin <marcin.j.chrzanowski@gmail.com>2019-11-24 22:09:41 +0100
committerGitHub <noreply@github.com>2019-11-24 22:09:41 +0100
commitac7aa67be63bea11246b5d39d1ff2bd7d16d2a1c (patch)
treed88a506d46f4c9410d0575805bde01528192bb5e
parente24fbbecfb9b631d9467b204a1b87c593746886b (diff)
Pass registry address to fetcher (#41)
-rw-r--r--build.gradle1
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java21
2 files changed, 21 insertions, 1 deletions
diff --git a/build.gradle b/build.gradle
index 751927a..237ff87 100644
--- a/build.gradle
+++ b/build.gradle
@@ -59,6 +59,7 @@ task runClient(type: JavaExec) {
task runFetcher(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
main = 'pl.edu.mimuw.cloudatlas.fetcher.Fetcher'
+ args("localhost", 1099)
}
task runInterpreter(type: JavaExec) {
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<String> 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();
}
}