From 122cd67070e9475eea509a1d6550ce1f43e4bfb6 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Fri, 15 Nov 2019 15:46:53 +0100 Subject: Add API definition --- .../java/pl/edu/mimuw/cloudatlas/agent/Agent.java | 2 ++ .../java/pl/edu/mimuw/cloudatlas/agent/Api.java | 11 ------- .../mimuw/cloudatlas/agent/ApiImplementation.java | 25 ++++++++++---- src/main/java/pl/edu/mimuw/cloudatlas/api/Api.java | 38 ++++++++++++++++++++++ .../pl/edu/mimuw/cloudatlas/client/Client.java | 2 +- .../pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java | 2 +- 6 files changed, 61 insertions(+), 19 deletions(-) delete mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java create mode 100644 src/main/java/pl/edu/mimuw/cloudatlas/api/Api.java (limited to 'src/main/java') 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 79df04e..cb059dd 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java @@ -5,6 +5,8 @@ import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; +import pl.edu.mimuw.cloudatlas.api.Api; + public class Agent { public static void main(String[] args) { try { diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java deleted file mode 100644 index c0003a8..0000000 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java +++ /dev/null @@ -1,11 +0,0 @@ -package pl.edu.mimuw.cloudatlas.agent; - -import java.rmi.Remote; -import java.rmi.RemoteException; - -import pl.edu.mimuw.cloudatlas.model.ValueSet; - -public interface Api extends Remote { - public int ping(int n) throws RemoteException; - public ValueSet getZones() throws RemoteException; -} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java index fc7532d..fd52052 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java @@ -5,19 +5,32 @@ import java.rmi.RemoteException; import java.util.Set; import java.util.HashSet; +import pl.edu.mimuw.cloudatlas.model.AttributesMap; +import pl.edu.mimuw.cloudatlas.model.ValueContact; import pl.edu.mimuw.cloudatlas.model.Value; import pl.edu.mimuw.cloudatlas.model.ValueSet; import pl.edu.mimuw.cloudatlas.model.ValueNull; import pl.edu.mimuw.cloudatlas.model.TypePrimitive; +import pl.edu.mimuw.cloudatlas.api.Api; public class ApiImplementation implements Api { - public int ping(int n) throws RemoteException { - return n + 1; + public Set getZoneSet() throws RemoteException { + return null; } - public ValueSet getZones() throws RemoteException { - Set set = new HashSet(); - set.add(ValueNull.getInstance()); - return new ValueSet(set, TypePrimitive.STRING); + public AttributesMap getZoneAttributeValue(String zoneName) throws RemoteException { + return null; + } + + public void installQuery(String queryName, String query) throws RemoteException { + } + + public void uninstallQuery(String queryName) throws RemoteException { + } + + public void setAttributeValue(String attributeName, Value value) throws RemoteException { + } + + public void setFallbackContacts(Set serializedContacts) throws RemoteException { } } diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/api/Api.java b/src/main/java/pl/edu/mimuw/cloudatlas/api/Api.java new file mode 100644 index 0000000..c5a4581 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/api/Api.java @@ -0,0 +1,38 @@ +package pl.edu.mimuw.cloudatlas.api; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +import pl.edu.mimuw.cloudatlas.model.Value; +import pl.edu.mimuw.cloudatlas.model.ValueContact; +import pl.edu.mimuw.cloudatlas.model.AttributesMap; + +/** + * + * from: https://www.mimuw.edu.pl/~iwanicki/courses/ds/2019/labs/04/ + + Returning the set of zones on which the agent stores information. + Returning the values of attributes of a given zone. + Installing a query on the agent. We assume that the query is installed in all zones of the agent. + Uninstalling a query on the agent. Again, the query is uninstalled from all zones of the agent. + Setting the values of attributes of a given zone (this operation should be allowed only for the singleton zones). + Setting the fallback contacts. These contacts are stored aside from the ZMIs, in a dedicated set. Each invocation of the function overrides this set. + + */ +import java.util.Set; + +public interface Api extends Remote { + + public Set getZoneSet() throws RemoteException; + + public AttributesMap getZoneAttributeValue(String zoneName) throws RemoteException; + + public void installQuery(String queryName, String query) throws RemoteException; + + public void uninstallQuery(String queryName) throws RemoteException; + + public void setAttributeValue(String attributeName, Value value) throws RemoteException; + + public void setFallbackContacts(Set serializedContacts) throws RemoteException; + +} diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java b/src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java index e573d6c..96fe14f 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java @@ -1,6 +1,6 @@ package pl.edu.mimuw.cloudatlas.client; -import pl.edu.mimuw.cloudatlas.agent.Api; +import pl.edu.mimuw.cloudatlas.api.Api; import java.rmi.registry.LocateRegistry; import java.rmi.RemoteException; 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 67d7165..f7fdab2 100644 --- a/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java +++ b/src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java @@ -1,6 +1,6 @@ package pl.edu.mimuw.cloudatlas.fetcher; -import pl.edu.mimuw.cloudatlas.agent.Api; +import pl.edu.mimuw.cloudatlas.api.Api; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; -- cgit v1.2.3