From a998cf78297233efe4886ade4f9d440244836353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Grodzi=C5=84ska?= Date: Wed, 15 Jan 2020 22:22:19 +0100 Subject: Add initial contact to self with flag --- build.gradle | 5 +++++ src/main/java/pl/edu/mimuw/cloudatlas/agent/AgentConfig.java | 4 ++++ src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 51a49c5..201f249 100644 --- a/build.gradle +++ b/build.gradle @@ -58,6 +58,10 @@ ext.fallbackContacts = { return System.getProperty("fallbackContacts") ?: "{\"" + zonePath() + "\":[127,0,0,1]}" } +ext.ownAddr = { + return System.getProperty("ownZone") ?: "localhost" +} + /* Possible options: RoundRobinExp @@ -147,6 +151,7 @@ task runFetcher(type: JavaExec) { args(hostname() , 1099) systemProperty 'zone_path', zonePath() systemProperty 'fallback_contacts', fallbackContacts() + systemProperty 'own_addr', ownAddr() } task runInterpreter(type: JavaExec) { diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/AgentConfig.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/AgentConfig.java index ad0f3bd..7b03f60 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/AgentConfig.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/AgentConfig.java @@ -1,9 +1,13 @@ package pl.edu.mimuw.cloudatlas.agent; +import pl.edu.mimuw.cloudatlas.agent.messages.StateMessage; +import pl.edu.mimuw.cloudatlas.agent.messages.UpdateAttributesMessage; import pl.edu.mimuw.cloudatlas.agent.modules.*; import pl.edu.mimuw.cloudatlas.agent.modules.Module; import pl.edu.mimuw.cloudatlas.api.Api; +import pl.edu.mimuw.cloudatlas.model.AttributesMap; import pl.edu.mimuw.cloudatlas.model.PathName; +import pl.edu.mimuw.cloudatlas.model.ValueContact; import java.net.InetAddress; import java.net.SocketException; 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 2b8d033..096e4e3 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java @@ -1,7 +1,11 @@ package pl.edu.mimuw.cloudatlas.fetcher; +import pl.edu.mimuw.cloudatlas.agent.EventBus; +import pl.edu.mimuw.cloudatlas.agent.messages.UpdateAttributesMessage; import pl.edu.mimuw.cloudatlas.api.Api; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; @@ -98,7 +102,8 @@ public class Fetcher { System.out.println(System.getProperty("user.dir")); String fallbackContactsString = System.getProperty("fallback_contacts"); - System.out.println(fallbackContactsString); + String ownAddr = System.getProperty("own_addr"); + try { initializeApiStub(); initializePythonProcess(); @@ -108,6 +113,9 @@ public class Fetcher { Set fallbackContacts = new HashSet(); api.setFallbackContacts(ClientController.parseContactsString(fallbackContactsString)); + ValueContact initialContact = new ValueContact(new PathName(zonePath), InetAddress.getByName(ownAddr)); + api.setAttributeValue(zonePath, "contacts", initialContact); + while((jsonAttribs = bufferRead.readLine()) != null) { System.out.println(jsonAttribs); System.out.flush(); -- cgit v1.2.3