m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();
}
}