m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/Agent.java2
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/Api.java11
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/agent/ApiImplementation.java25
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/api/Api.java38
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/client/Client.java2
-rw-r--r--src/main/java/pl/edu/mimuw/cloudatlas/fetcher/Fetcher.java2
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java11
7 files changed, 68 insertions, 23 deletions
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<String> getZoneSet() throws RemoteException {
+ return null;
}
- public ValueSet getZones() throws RemoteException {
- Set<Value> 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<ValueContact> 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<String> 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<ValueContact> 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;
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java
index baf77ea..6ab10d6 100644
--- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java
+++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/AgentTest.java
@@ -11,11 +11,15 @@ import java.lang.Thread;
import java.io.InputStream;
+import java.util.Set;
+
import java.rmi.registry.LocateRegistry;
import java.rmi.RemoteException;
import java.rmi.registry.Registry;
import java.math.BigDecimal;
+import pl.edu.mimuw.cloudatlas.api.Api;
+
public class AgentTest {
private static Process registryProcess;
private static Process agentProcess;
@@ -39,14 +43,13 @@ public class AgentTest {
}
@Test
- public void testPing() {
+ public void testGetZoneSet() {
try {
Registry registry = LocateRegistry.getRegistry("localhost");
Api api = (Api) registry.lookup("Api");
- int res = api.ping(10);
- assertEquals(11, res);
+ Set<String> set = api.getZoneSet();
+ assertEquals(null, set);
} catch (Exception e) {
- System.err.println("FibonacciClient exception:");
e.printStackTrace();
assertTrue(false);
}