summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/derms/Replica1.java121
-rw-r--r--src/main/java/derms/Replica4.java216
-rw-r--r--src/main/java/derms/ReplicaManager.java4
-rw-r--r--src/main/java/derms/frontend/FE.java85
-rw-r--r--src/main/java/derms/replica1/CentralRepo.java29
-rw-r--r--src/main/java/derms/replica1/CentralRepoInterface.java14
-rw-r--r--src/main/java/derms/replica1/CoordinatorClient.java101
-rw-r--r--src/main/java/derms/replica1/DERMSInterface.java41
-rw-r--r--src/main/java/derms/replica1/DERMSServer.java504
-rw-r--r--src/main/java/derms/replica1/DERMSServerPublisher.java16
-rw-r--r--src/main/java/derms/replica1/Replica1.java80
-rw-r--r--src/main/java/derms/replica1/Requester.java32
-rw-r--r--src/main/java/derms/replica1/Resource.java48
-rw-r--r--src/main/java/derms/replica1/ResponderClient.java106
-rw-r--r--src/main/java/derms/replica1/UDPUtilities.java18
-rw-r--r--src/main/java/derms/replica1/jaxws/AddResource.classbin0 -> 1011 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/AddResource.java106
-rw-r--r--src/main/java/derms/replica1/jaxws/AddResourceResponse.classbin0 -> 760 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/AddResourceResponse.java62
-rw-r--r--src/main/java/derms/replica1/jaxws/DERMSInterface.classbin0 -> 3941 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/DERMSInterface.java166
-rw-r--r--src/main/java/derms/replica1/jaxws/DERMSServerService.classbin0 -> 2339 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/DERMSServerService.java94
-rw-r--r--src/main/java/derms/replica1/jaxws/FindResource.classbin0 -> 855 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/FindResource.java87
-rw-r--r--src/main/java/derms/replica1/jaxws/FindResourceResponse.classbin0 -> 864 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/FindResourceResponse.java69
-rw-r--r--src/main/java/derms/replica1/jaxws/ListResourceAvailability.classbin0 -> 725 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/ListResourceAvailability.java60
-rw-r--r--src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.classbin0 -> 900 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.java69
-rw-r--r--src/main/java/derms/replica1/jaxws/ObjectFactory.classbin0 -> 8195 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/ObjectFactory.java287
-rw-r--r--src/main/java/derms/replica1/jaxws/RemoveResource.classbin0 -> 857 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/RemoveResource.java79
-rw-r--r--src/main/java/derms/replica1/jaxws/RemoveResourceResponse.classbin0 -> 769 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/RemoveResourceResponse.java62
-rw-r--r--src/main/java/derms/replica1/jaxws/RequestResource.classbin0 -> 1026 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/RequestResource.java106
-rw-r--r--src/main/java/derms/replica1/jaxws/RequestResourceResponse.classbin0 -> 772 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/RequestResourceResponse.java62
-rw-r--r--src/main/java/derms/replica1/jaxws/ReturnResource.classbin0 -> 855 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/ReturnResource.java87
-rw-r--r--src/main/java/derms/replica1/jaxws/ReturnResourceResponse.classbin0 -> 769 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/ReturnResourceResponse.java62
-rw-r--r--src/main/java/derms/replica1/jaxws/SwapResource.classbin0 -> 1368 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/SwapResource.java168
-rw-r--r--src/main/java/derms/replica1/jaxws/SwapResourceResponse.classbin0 -> 763 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/SwapResourceResponse.java62
-rw-r--r--src/main/java/derms/replica1/jaxws/package-info.classbin0 -> 248 bytes
-rw-r--r--src/main/java/derms/replica1/jaxws/package-info.java2
-rw-r--r--src/main/java/derms/replica2/DermsLogger.java4
52 files changed, 2841 insertions, 268 deletions
diff --git a/src/main/java/derms/Replica1.java b/src/main/java/derms/Replica1.java
deleted file mode 100644
index ad8b7a0..0000000
--- a/src/main/java/derms/Replica1.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package derms;
-
-import derms.net.runicast.ReliableUnicastSender;
-
-import javax.xml.ws.Endpoint;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.logging.Logger;
-
-public class Replica1 implements Replica {
- @Override
- public boolean isAlive() {
- return false;
- }
-
- @Override
- public void startProcess() {
-
- }
-
- @Override
- public void processRequest(Request request) {
-
- }
-
- @Override
- public void restart() {
-
- }
-
- @Override
- public int getId() {
- return 0;
- }
-// private final ReliableUnicastSender<Response> unicastSender;
-// ReplicaManager replicaManager;
-// private final Logger log;
-// private boolean alive = true;
-//
-// public Replica1( InetSocketAddress frontEndAddress) throws IOException {
-// this.unicastSender = new ReliableUnicastSender<Response>(frontEndAddress);
-// this.log = Logger.getLogger(getClass().getName());
-// }
-//
-//
-// @Override
-// public boolean isAlive() {
-// return alive;
-// }
-//
-// @Override
-// public void startProcess() {
-// // Simulate the replica process starting.
-// log.info("Replica " + 1 + " started.");
-// }
-//
-// @Override
-// public void processRequest(Request request) {
-// // Process the request and create a response.
-// endpoint1 = Endpoint.publish("http://localhost:8080/ws/derms", new DERMSServer("MTL"));
-// endpoint2 = Endpoint.publish("http://localhost:8081/ws/derms", new DERMSServer("QUE"));
-// endpoint3 = Endpoint.publish("http://localhost:8082/ws/derms", new DERMSServer("SHE"));
-//
-//
-// String responseMessage;
-// switch (request.getFunction()) {
-// case "addResource":
-// responderClient = new ResponderClient(request.getClientID());
-// responseMessage = responderClient.addResource(request.getResourceID(), request.getResourceType(), request.getDuration());
-// break;
-// case "removeResource":
-// responderClient = new ResponderClient(request.getClientID());
-// responseMessage = responderClient.removeResource(request.getResourceID(), request.getDuration());
-// break;
-// case "listResourceAvailability":
-// responderClient = new ResponderClient(request.getClientID());
-// responseMessage = responderClient.listResourceAvailability(request.getResourceType());
-// break;
-// case "requestResource":
-// coordinatorClient = new CoordinatorClient(request.getClientID());
-// responseMessage = coordinatorClient.requestResource(request.getClientID(), request.getResourceID(), request.getDuration());
-// break;
-// case "findResource":
-// coordinatorClient = new CoordinatorClient(request.getClientID());
-// responseMessage = coordinatorClient.findResource(request.getClientID(), request.getResourceType());
-// break;
-// case "returnResource":
-// coordinatorClient = new CoordinatorClient(request.getClientID());
-// responseMessage = coordinatorClient.returnResource(request.getClientID(), request.getResourceID());
-// break;
-// case "swapResource":
-// coordinatorClient = new CoordinatorClient(request.getClientID());
-// responseMessage = coordinatorClient.swapResource(
-// request.getClientID(),
-// request.getOldResourceID(),
-// request.getOldResourceType(),
-// request.getResourceID(),
-// request.getResourceType()
-// );
-// break;
-// default:
-// responseMessage = "Unrecognized function: " + request.getFunction();
-// log.severe("Unrecognized function in request: " + request.getFunction());
-// break;
-// }
-//
-// Response response = new Response(request.getSequenceNumber(), responseMessage);
-// log.info("Replica " + 1 + " processed request: " + request + ", response: " + response);
-// replicaManager.sendResponseToFE(response);
-// }
-//
-// @Override
-// public void restart() {
-// // Restart the replica process.
-// log.warning("Replica " + 1 + " is restarting...");
-// startProcess();
-// }
-//
-// @Override
-// public int getId() { return 1; }
-} \ No newline at end of file
diff --git a/src/main/java/derms/Replica4.java b/src/main/java/derms/Replica4.java
index 760f8bb..ed7e90b 100644
--- a/src/main/java/derms/Replica4.java
+++ b/src/main/java/derms/Replica4.java
@@ -1,108 +1,108 @@
-package derms;
-
-//import derms.Replica3pkg.ResponderClient;
-import java.io.*;
-import java.util.*;
-
-import derms.Replica4pkg.RemoteServer;
-
-public class Replica4 implements Replica {
-
- private ReplicaManager replicaManager;
- private RemoteServer remoteServer;
- private boolean alive = true;
-
- public Replica4(ReplicaManager replicaManager){
- this.replicaManager = replicaManager;
- }
-
- @Override
- public boolean isAlive() {
- return alive;
- }
-
- @Override
- public void startProcess() {
- this.remoteServer = new RemoteServer();
- System.out.println("[Replica 4] Process started.");
- }
-
- @Override
- public void processRequest(Request request) {
- ResponderClient responderClient;
- CoordinatorClient coordinatorClient;
- String responseMessage;
- switch (request.getFunction()) {
- case "addResource":
- responderClient = new ResponderClient(request.getClientID());
- responseMessage = responderClient.addResource(request.getResourceID(), request.getResourceType(), request.getDuration());
- break;
- case "removeResource":
- responderClient = new ResponderClient(request.getClientID());
- responseMessage = responderClient.removeResource(request.getResourceID(), request.getDuration());
- break;
- case "listResourceAvailability":
- responderClient = new ResponderClient(request.getClientID());
- responseMessage = responderClient.listResourceAvailability(request.getResourceType());
- break;
- case "requestResource":
- coordinatorClient = new CoordinatorClient(request.getClientID());
- responseMessage = coordinatorClient.requestResource(request.getResourceID(), request.getDuration());
- break;
- case "findResource":
- coordinatorClient = new CoordinatorClient(request.getClientID());
- responseMessage = coordinatorClient.findResource(request.getResourceType());
- break;
- case "returnResource":
- coordinatorClient = new CoordinatorClient(request.getClientID());
- responseMessage = coordinatorClient.returnResource(request.getResourceID());
- break;
- case "swapResource":
- coordinatorClient = new CoordinatorClient(request.getClientID());
- responseMessage = coordinatorClient.swapResource(
- request.getClientID(),
- request.getOldResourceID(),
- request.getOldResourceType(),
- request.getResourceID(),
- request.getResourceType()
- );
- break;
- default:
- responseMessage = "Unrecognized function: " + request.getFunction();
- log("Unrecognized function in request: " + request.getFunction());
- break;
- }
-
- Response response = new Response(request.getSequenceNumber(), responseMessage);
- log("Replica " + 4 + " processed request: " + request + ", response: " + response);
- replicaManager.sendResponseToFE(response);
- }
-
- @Override
- public void restart() {
- shutDown();
- startProcess();
- }
-
- public void shutDown(){
- this.remoteServer.stopServers();
- }
-
- @Override
- public int getId() {
- return 4;
- }
-
- public synchronized void log(String message) {
- String logMessage = new Date() + " - " + message;
- System.out.println(logMessage);
-
- try (FileWriter fw = new FileWriter("Replica4_log.txt", true);
- BufferedWriter bw = new BufferedWriter(fw);
- PrintWriter out = new PrintWriter(bw)) {
- out.println(logMessage);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-} \ No newline at end of file
+//package derms;
+//
+////import derms.Replica3pkg.ResponderClient;
+//import java.io.*;
+//import java.util.*;
+//
+//import derms.Replica4pkg.RemoteServer;
+//
+//public class Replica4 implements Replica {
+//
+// private ReplicaManager replicaManager;
+// private RemoteServer remoteServer;
+// private boolean alive = true;
+//
+// public Replica4(ReplicaManager replicaManager){
+// this.replicaManager = replicaManager;
+// }
+//
+// @Override
+// public boolean isAlive() {
+// return alive;
+// }
+//
+// @Override
+// public void startProcess() {
+// this.remoteServer = new RemoteServer();
+// System.out.println("[Replica 4] Process started.");
+// }
+//
+// @Override
+// public void processRequest(Request request) {
+// ResponderClient responderClient;
+// CoordinatorClient coordinatorClient;
+// String responseMessage;
+// switch (request.getFunction()) {
+// case "addResource":
+// responderClient = new ResponderClient(request.getClientID());
+// responseMessage = responderClient.addResource(request.getResourceID(), request.getResourceType(), request.getDuration());
+// break;
+// case "removeResource":
+// responderClient = new ResponderClient(request.getClientID());
+// responseMessage = responderClient.removeResource(request.getResourceID(), request.getDuration());
+// break;
+// case "listResourceAvailability":
+// responderClient = new ResponderClient(request.getClientID());
+// responseMessage = responderClient.listResourceAvailability(request.getResourceType());
+// break;
+// case "requestResource":
+// coordinatorClient = new CoordinatorClient(request.getClientID());
+// responseMessage = coordinatorClient.requestResource(request.getResourceID(), request.getDuration());
+// break;
+// case "findResource":
+// coordinatorClient = new CoordinatorClient(request.getClientID());
+// responseMessage = coordinatorClient.findResource(request.getResourceType());
+// break;
+// case "returnResource":
+// coordinatorClient = new CoordinatorClient(request.getClientID());
+// responseMessage = coordinatorClient.returnResource(request.getResourceID());
+// break;
+// case "swapResource":
+// coordinatorClient = new CoordinatorClient(request.getClientID());
+// responseMessage = coordinatorClient.swapResource(
+// request.getClientID(),
+// request.getOldResourceID(),
+// request.getOldResourceType(),
+// request.getResourceID(),
+// request.getResourceType()
+// );
+// break;
+// default:
+// responseMessage = "Unrecognized function: " + request.getFunction();
+// log("Unrecognized function in request: " + request.getFunction());
+// break;
+// }
+//
+// Response response = new Response(request.getSequenceNumber(), responseMessage);
+// log("Replica " + 4 + " processed request: " + request + ", response: " + response);
+// replicaManager.sendResponseToFE(response);
+// }
+//
+// @Override
+// public void restart() {
+// shutDown();
+// startProcess();
+// }
+//
+// public void shutDown(){
+// this.remoteServer.stopServers();
+// }
+//
+// @Override
+// public int getId() {
+// return 4;
+// }
+//
+// public synchronized void log(String message) {
+// String logMessage = new Date() + " - " + message;
+// System.out.println(logMessage);
+//
+// try (FileWriter fw = new FileWriter("Replica4_log.txt", true);
+// BufferedWriter bw = new BufferedWriter(fw);
+// PrintWriter out = new PrintWriter(bw)) {
+// out.println(logMessage);
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+//} \ No newline at end of file
diff --git a/src/main/java/derms/ReplicaManager.java b/src/main/java/derms/ReplicaManager.java
index 93819a3..83c1897 100644
--- a/src/main/java/derms/ReplicaManager.java
+++ b/src/main/java/derms/ReplicaManager.java
@@ -1,7 +1,6 @@
package derms;
import derms.frontend.FEInterface;
-import derms.Replica1;
import derms.Request;
import derms.Response;
@@ -9,6 +8,7 @@ import derms.net.MessagePayload;
import derms.net.tomulticast.TotalOrderMulticastReceiver;
import derms.net.runicast.ReliableUnicastSender;
import derms.net.tomulticast.TotalOrderMulticastSender;
+import derms.replica1.Replica1;
import derms.replica2.Replica2;
import java.io.IOException;
@@ -50,7 +50,7 @@ public class ReplicaManager {
private void initReplica() throws IOException {
switch (replicaId) {
case 1:
- replica = new derms.replica2.Replica2(city, this);
+ replica = new Replica1(this);
break;
case 2:
replica = new derms.replica2.Replica2(city, this);
diff --git a/src/main/java/derms/frontend/FE.java b/src/main/java/derms/frontend/FE.java
index 8d6fc59..f29459c 100644
--- a/src/main/java/derms/frontend/FE.java
+++ b/src/main/java/derms/frontend/FE.java
@@ -6,13 +6,16 @@ import java.net.*;
import javax.xml.ws.Endpoint;
import derms.Config;
-import derms.Request;
-import derms.Response;
+import derms.Request;
+import derms.Response;
import derms.net.runicast.ReliableUnicastReceiver;
import derms.net.runicast.ReliableUnicastSender;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
//import constants.Constants;
@@ -25,6 +28,7 @@ public class FE {
private static final String RM_Multicast_group_address = Config.group.toString();
private static final int RM_Multicast_Port = 1234;
private static AtomicInteger sequenceIDGenerator = new AtomicInteger(0);
+ private static final ExecutorService executor = Executors.newFixedThreadPool(4);
public static void main(String[] args) {
try {
@@ -73,9 +77,10 @@ public class FE {
};
DERMSServerImpl servant = new DERMSServerImpl(inter);
Endpoint endpoint = Endpoint.publish(endpointURL(frontendIP), servant);
+
Runnable task = () -> {
- listenForUDPResponses(servant);
try {
+ listenForUDPResponses(servant);
sequencerSock.close();
} catch (Exception e) {
e.printStackTrace();
@@ -83,6 +88,7 @@ public class FE {
};
Thread thread = new Thread(task);
thread.start();
+
} catch (Exception e) {
// System.err.println("Exception: " + e);
e.printStackTrace(System.out);
@@ -167,47 +173,56 @@ public class FE {
// } catch (IOException e) {
// System.out.println("IO: " + e.getMessage());
// } finally {
-//// if (aSocket != null)
-//// aSocket.close();
+
+ /// / if (aSocket != null)
+ /// / aSocket.close();
// }
// }
-
private static void listenForUDPResponses(DERMSServerImpl servant) {
List<ReliableUnicastReceiver<Response>> receivers = new ArrayList<ReliableUnicastReceiver<Response>>();
- try {
- // Initialize a receiver for each RM.
- for (int port : Config.frontendResponsePorts) {
+ // Initialize a receiver for each RM.
+ for (int port : Config.frontendResponsePorts) {
+ try {
receivers.add(new ReliableUnicastReceiver<Response>(
new InetSocketAddress(frontendIP, port)));
- System.out.println("FE listening for responses on " + frontendIP + ":" + port + "...");
- }
-
- while (true) {
- // Receive a response from each RM.
- for (ReliableUnicastReceiver<Response> receiver : receivers) {
- // Blocking call to receive a message from RM
- Response response = receiver.receive();
- System.out.println("FE: Response received from RM >>> " + response);
-
- // Process the received response and add it to the servant
- System.out.println("Adding response to FrontEndImplementation:");
- servant.addReceivedResponse(response);
- }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- } catch (IOException e) {
- System.out.println("IO: " + e.getMessage());
- } catch (InterruptedException e) {
- System.out.println("Listener interrupted: " + e.getMessage());
- Thread.currentThread().interrupt();
- } finally {
- for (ReliableUnicastReceiver<Response> receiver : receivers) {
+ System.out.println("FE listening for responses on " + frontendIP + ":" + port + "...");
+ }
+ for (ReliableUnicastReceiver<Response> receiver : receivers) {
+ executor.execute(() -> {
try {
- receiver.close();
- System.out.println("ReliableUnicastReceiver closed.");
- } catch (IOException e) {
- System.out.println("Error closing ReliableUnicastReceiver: " + e.getMessage());
+ while (true) {
+ // Receive a response from each RM.
+
+ // Blocking call to receive a message from RM
+ Response response;
+
+ response = receiver.receive();
+ System.out.println("FE: Response received from RM >>> " + response);
+
+ // Process the received response and add it to the servant
+ System.out.println("Adding response to FrontEndImplementation:");
+ servant.addReceivedResponse(response);
+ }
+ } catch (InterruptedException e) {
+ System.out.println("Listener interrupted: " + e.getMessage());
+ Thread.currentThread().interrupt();
+ } finally {
+ try {
+ receiver.close();
+ System.out.println("ReliableUnicastReceiver closed.");
+ } catch (IOException e) {
+ System.out.println("Error closing ReliableUnicastReceiver: " + e.getMessage());
+ }
}
- }
+ });
+ }
+ try {
+ executor.awaitTermination(100, TimeUnit.HOURS);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
}
}
diff --git a/src/main/java/derms/replica1/CentralRepo.java b/src/main/java/derms/replica1/CentralRepo.java
new file mode 100644
index 0000000..fe1fc45
--- /dev/null
+++ b/src/main/java/derms/replica1/CentralRepo.java
@@ -0,0 +1,29 @@
+package derms.replica1;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.Endpoint;
+
+@WebService
+public class CentralRepo {
+
+ public static void main(String[] args) {
+ Endpoint.publish("http://localhost:8387/CentralRepo", new CentralRepo());
+ System.out.println("derms.CentralRepo is up and running...");
+ }
+
+ private final Map<String, Integer> serverNames = new HashMap<>();
+
+ @WebMethod
+ public Map<String, Integer> listServers() {
+ return serverNames;
+ }
+
+ @WebMethod
+ public void addServer(String serverName, int serverPort) {
+ serverNames.put(serverName, serverPort);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/CentralRepoInterface.java b/src/main/java/derms/replica1/CentralRepoInterface.java
new file mode 100644
index 0000000..5402516
--- /dev/null
+++ b/src/main/java/derms/replica1/CentralRepoInterface.java
@@ -0,0 +1,14 @@
+package derms.replica1;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import java.util.Map;
+
+@WebService
+public interface CentralRepoInterface {
+ @WebMethod
+ Map<String, Integer> listServers();
+
+ @WebMethod
+ void addServer(String serverName, int serverPort);
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/CoordinatorClient.java b/src/main/java/derms/replica1/CoordinatorClient.java
new file mode 100644
index 0000000..23b5a01
--- /dev/null
+++ b/src/main/java/derms/replica1/CoordinatorClient.java
@@ -0,0 +1,101 @@
+package derms.replica1;
+
+import derms.replica1.jaxws.DERMSInterface;
+import derms.replica1.jaxws.DERMSServerService;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.time.LocalDateTime;
+
+public class CoordinatorClient {
+ private final DERMSInterface server;
+ private String coordinatorID;
+
+ public CoordinatorClient(String coordinatorID) {
+ try {
+ this.coordinatorID = coordinatorID;
+ HashMap<String, String> servers = new HashMap<String, String>() {{
+ put("MTL", "http://localhost:8387/ws/derms?wsdl");
+ put("QUE", "http://localhost:8081/ws/derms?wsdl");
+ put("SHE", "http://localhost:8082/ws/derms?wsdl");
+ }};
+ URL url = new URL(servers.get(coordinatorID.substring(0, 3)));
+ DERMSServerService service = new DERMSServerService(url);
+ server = service.getDERMSServerPort();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String requestResource(String coordinatorID, String resourceID, int duration) {
+ try {
+ String response = server.requestResource(coordinatorID, resourceID, duration);
+ logOperation("requestResource", coordinatorID, resourceID, duration, response);
+ return response;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public List<String> findResource(String coordinatorID, String resourceName) {
+ try {
+ List<String> response = server.findResource(coordinatorID, resourceName);
+ logOperation("findResource", coordinatorID, resourceName, response.toString());
+ return response;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return Collections.emptyList();
+ }
+
+ public void returnResource(String coordinatorID, String resourceID) {
+ try {
+ String response = server.returnResource(coordinatorID, resourceID);
+ System.out.println(response);
+ logOperation("returnResource", coordinatorID, resourceID, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ public String swapResource(String coordinatorID, String oldResourceID, String oldResourceType, String newResourceID, String newResourceType) {
+ try {
+ String response = server.swapResource(coordinatorID, oldResourceID, oldResourceType, newResourceID, newResourceType);
+ logOperation("swapResource", coordinatorID, oldResourceID, newResourceID, response);
+ return response;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private void logOperation(String operation, String coordinatorID, String oldResourceID, String newResourceID, String response) {
+ try (FileWriter writer = new FileWriter(coordinatorID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + coordinatorID + " - " + oldResourceID + " - " + newResourceID + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ private void logOperation(String operation, String coordinatorID, String resourceID, int duration, String response) {
+ try (FileWriter writer = new FileWriter(coordinatorID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + coordinatorID + " - " + resourceID + " - " + duration + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void logOperation(String operation, String coordinatorID, String resourceName, String response) {
+ try (FileWriter writer = new FileWriter(coordinatorID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + coordinatorID + " - " + resourceName + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/DERMSInterface.java b/src/main/java/derms/replica1/DERMSInterface.java
new file mode 100644
index 0000000..7fda81c
--- /dev/null
+++ b/src/main/java/derms/replica1/DERMSInterface.java
@@ -0,0 +1,41 @@
+package derms.replica1;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import java.util.List;
+
+@WebService
+public interface DERMSInterface {
+ @WebMethod
+ String addResource(@WebParam(name = "resourceID") String resourceID,
+ @WebParam(name = "resourceName") String resourceName,
+ @WebParam(name = "duration") int duration);
+
+ @WebMethod
+ String removeResource(@WebParam(name = "resourceID") String resourceID,
+ @WebParam(name = "duration") int duration);
+
+ @WebMethod
+ List<String> listResourceAvailability(@WebParam(name = "resourceName") String resourceName);
+
+ @WebMethod
+ String requestResource(@WebParam(name = "coordinatorID") String coordinatorID,
+ @WebParam(name = "resourceID") String resourceID,
+ @WebParam(name = "duration") int duration);
+
+ @WebMethod
+ List<String> findResource(@WebParam(name = "coordinatorID") String coordinatorID,
+ @WebParam(name = "resourceName") String resourceName);
+
+ @WebMethod
+ String returnResource(@WebParam(name = "coordinatorID") String coordinatorID,
+ @WebParam(name = "resourceID") String resourceID);
+
+ @WebMethod
+ String swapResource(@WebParam(name = "coordinatorID") String coordinatorID,
+ @WebParam(name = "oldResourceID") String oldResourceID,
+ @WebParam(name = "oldResourceType") String oldResourceType,
+ @WebParam(name = "newResourceID") String newResourceID,
+ @WebParam(name = "newResourceType") String newResourceType);
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/DERMSServer.java b/src/main/java/derms/replica1/DERMSServer.java
new file mode 100644
index 0000000..72849a1
--- /dev/null
+++ b/src/main/java/derms/replica1/DERMSServer.java
@@ -0,0 +1,504 @@
+package derms.replica1;
+
+import javax.jws.WebService;
+import javax.xml.ws.Endpoint;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.time.LocalDateTime;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+@WebService(endpointInterface = "derms.replica1.DERMSInterface")
+public class DERMSServer implements DERMSInterface {
+ private HashMap<String, Resource> resources;
+ private String serverID;
+ private AtomicInteger serverPort = new AtomicInteger();
+ private ConcurrentSkipListSet<String> requests = new ConcurrentSkipListSet<>();
+
+ private static List<String> cities = Arrays.asList("MTL", "QUE", "SHE");
+ private static List<String> resourceNames = Arrays.asList("AMBULANCE", "FIRETRUCK", "PERSONNEL");
+
+ public DERMSServer() {
+ // Default constructor to support JAX-WS
+ super();
+ this.serverID = "MTL";
+ resources = new HashMap<>();
+ new Thread(this::listenForMessages).start();
+ }
+
+ public DERMSServer(String serverID) throws InterruptedException {
+ super();
+ this.serverID = serverID;
+ resources = new HashMap<>();
+ new Thread(this::listenForMessages).start();
+ Thread.sleep(10);
+ }
+
+ private void listenForMessages() {
+ try (DatagramSocket socket = new DatagramSocket()) {
+ this.serverPort.set(socket.getLocalPort());
+ byte[] buffer = new byte[1024];
+
+ while (true) {
+ DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
+ socket.receive(packet);
+ String message = new String(packet.getData(), 0, packet.getLength());
+ if (message.equals("DIE")) break;
+ String response = handleUDPMessage(message);
+ byte[] responseBytes = response.getBytes();
+ DatagramPacket responsePacket = new DatagramPacket(
+ responseBytes, responseBytes.length, packet.getAddress(), packet.getPort());
+ socket.send(responsePacket);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String handleUDPMessage(String message) {
+ String[] parts = message.split(" ");
+ String command = parts[0];
+
+ try {
+ switch (command) {
+ case "REQUEST_RESOURCE":
+ return requestResource(parts[1], parts[2], Integer.parseInt(parts[3]));
+ case "FIND_RESOURCE":
+ return String.join(",", localFindResource(parts[1], parts[2]));
+ case "LIST_RESOURCE_AVAILABILITY":
+ return String.join(",", localListResourceAvailability(parts[1]));
+ case "DIE":
+ return "DIE";
+ default:
+ return "UNKNOWN_COMMAND";
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return "ERROR";
+ }
+ }
+
+ private String sendMessage(String message, String host, int port) throws Exception {
+ DatagramSocket socket = new DatagramSocket();
+ InetAddress address = InetAddress.getByName(host);
+
+ byte[] buffer = message.getBytes();
+ DatagramPacket request = new DatagramPacket(buffer, buffer.length, address, port);
+
+ socket.send(request);
+
+ byte[] responseBuffer = new byte[1024];
+ DatagramPacket response = new DatagramPacket(responseBuffer, responseBuffer.length);
+
+ socket.receive(response);
+
+ socket.close();
+
+ return new String(response.getData(), 0, response.getLength());
+ }
+
+ @Override
+ public synchronized String addResource(String resourceID,
+ String resourceName,
+ int duration) {
+ String response;
+ boolean success = false;
+ String validation = validInput(resourceID, resourceName, duration);
+ if (validation == null) {
+ if (resources.containsKey(resourceID)) {
+ Resource resource = resources.get(resourceID);
+ if (duration > resource.getDuration()) {
+ resource.setDuration(duration);
+ response = "derms.Resource duration updated successfully.";
+ success = true;
+ } else {
+ response = "derms.Resource already exists with equal or longer duration.";
+ }
+ } else {
+ resources.put(resourceID, new Resource(resourceID, resourceName, duration));
+ response = "derms.Resource added successfully.";
+ success = true;
+ }
+ } else {
+ response = validation;
+ }
+// System.out.println(resources);
+ logOperation("addResource", resourceID, resourceName, duration, success, response);
+ return response;
+ }
+
+ @Override
+ public synchronized String removeResource(String resourceID,
+ int duration) {
+ String response;
+ boolean success = false;
+ String validation = validInput(resourceID, resourceNames.get(0), duration);
+ if (validation == null) {
+ if (resources.containsKey(resourceID)) {
+ Resource resource = resources.get(resourceID);
+ if (duration < resource.getDuration()) {
+ resource.setDuration(resource.getDuration() - duration);
+ response = "derms.Resource duration decreased successfully.";
+ } else {
+ resources.remove(resourceID);
+ response = "derms.Resource removed successfully.";
+ }
+ success = true;
+ } else {
+ response = "derms.Resource does not exist.";
+ }
+ } else {
+ response = validation;
+ }
+ logOperation("removeResource", resourceID, duration, success, response);
+ return response;
+ }
+
+ @Override
+ public List<String> listResourceAvailability(String resourceName) {
+ String requestID = UUID.randomUUID().toString();
+ return listResourceAvailability(requestID, resourceName);
+ }
+
+ public List<String> localListResourceAvailability(String resourceName) {
+ List<String> availableResources = new ArrayList<>();
+ for (Resource resource : resources.values()) {
+ if (resource.getResourceName().equals(resourceName)) {
+ availableResources.add(resource.toString());
+ }
+ }
+ return availableResources;
+ }
+
+ public List<String> listResourceAvailability(String requestID, String resourceName) {
+ if (!requests.contains(requestID)) {
+ requests.add(requestID);
+ } else {
+ return Arrays.asList();
+ }
+
+ // Assuming a method for fetching the server names and ports via web services
+ Map<String, Integer> serverNames = getServerPortsFromCentralRepo();
+
+ serverNames.remove(serverID);
+ List<Callable<List<String>>> callables = new ArrayList<>();
+ for (Map.Entry<String, Integer> server : serverNames.entrySet()) {
+ callables.add(() -> Arrays.asList(sendMessage(String.format("LIST_RESOURCE_AVAILABILITY %s", resourceName), "localhost", server.getValue()).split(",")));
+ }
+ ExecutorService executor = Executors.newFixedThreadPool(5);
+ List<Future<List<String>>> results;
+ try {
+ results = executor.invokeAll(callables);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ List<String> availableResources = new ArrayList<>();
+ for (Resource resource : resources.values()) {
+ if (resource.getResourceName().equals(resourceName)) {
+ availableResources.add(resource.toString());
+ }
+ }
+ for (Future<List<String>> f : results) {
+ try {
+ availableResources.addAll(f.get().stream().filter((s) -> !s.isEmpty()).collect(Collectors.toList()));
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ logOperation("listResourceAvailability", serverID, true, availableResources.toString());
+ return availableResources;
+ }
+
+ private Map<String, Integer> getServerPortsFromCentralRepo() {
+ // Mocking response as web services since no derms.CentralRepoInterface.
+ return new HashMap<String, Integer>() {{
+ put("MTL", 4321);
+ put("QUE", 4322);
+ put("SHE", 4323);
+ }};
+ }
+
+ @Override
+ public synchronized String requestResource(String coordinatorID,
+ String resourceID,
+ int duration) {
+ String response;
+ boolean success = false;
+ List<String> others = new ArrayList<>(getServerPortsFromCentralRepo().keySet());
+ others.remove(serverID);
+
+ String validation = validInput(resourceID, resourceNames.get(0), duration);
+ if (validation == null) {
+// System.out.println(resources);
+ if (resources.containsKey(resourceID)) {
+ Resource resource = resources.get(resourceID);
+ if (duration <= resource.getDuration() && !resource.borrowed) {
+ resource.setDuration(resource.getDuration() - duration);
+ resource.borrowed = true;
+ resource.borrower = coordinatorID;
+ response = "derms.Resource requested successfully.";
+ success = true;
+ } else {
+ resource.requesters.add(0, new Requester(coordinatorID, duration));
+ response = "Insufficient resource duration.";
+ }
+ } else if (others.contains(resourceID.substring(0, 3))) {
+ try {
+ return sendMessage(String.format("REQUEST_RESOURCE %s %s %d", coordinatorID, resourceID, duration), "localhost", getServerPortsFromCentralRepo().get(resourceID.substring(0, 3)));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ response = "derms.Resource does not exist.";
+ }
+ } else {
+ response = validation;
+ }
+ logOperation("requestResource", coordinatorID, resourceID, duration, success, response);
+ return response;
+ }
+
+ @Override
+ public List<String> findResource(String coordinatorID,
+ String resourceName) {
+ String requestID = UUID.randomUUID().toString();
+ return findResource(requestID, coordinatorID, resourceName);
+ }
+
+ public List<String> localFindResource(String coordinatorID,
+ String resourceName) {
+ List<String> foundResources = new ArrayList<>();
+ for (Resource resource : resources.values()) {
+ if (resource.getResourceName().equals(resourceName)) {
+ foundResources.add(resource.toString());
+ }
+ }
+ return foundResources;
+ }
+
+ public List<String> findResource(String requestID, String coordinatorID, String resourceName) {
+ if (!requests.contains(requestID)) {
+ requests.add(requestID);
+ } else {
+ return Arrays.asList();
+ }
+
+ if (!resourceNames.contains(resourceName)) {
+ logOperation("findResource", coordinatorID, resourceName, false, "No resources found.");
+ return Arrays.asList();
+ }
+
+ Map<String, Integer> serverNames = getServerPortsFromCentralRepo();
+
+ serverNames.remove(serverID);
+ List<Callable<List<String>>> callables = new ArrayList<>();
+ for (Map.Entry<String, Integer> server : serverNames.entrySet()) {
+ callables.add(() -> Arrays.asList(sendMessage(String.format("FIND_RESOURCE %s %s", coordinatorID, resourceName), "localhost", server.getValue()).split(",")));
+ }
+ ExecutorService executor = Executors.newFixedThreadPool(5);
+ List<Future<List<String>>> results;
+ try {
+ results = executor.invokeAll(callables);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ List<String> foundResources = new ArrayList<>();
+ for (Resource resource : resources.values()) {
+ if (resource.getResourceName().equals(resourceName)) {
+ foundResources.add(resource.toString());
+ }
+ }
+ for (Future<List<String>> f : results) {
+ try {
+ foundResources.addAll(f.get().stream().filter((s) -> !s.isEmpty()).collect(Collectors.toList()));
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ logOperation("findResource", coordinatorID, resourceName, true, foundResources.toString());
+ return foundResources;
+ }
+
+ @Override
+ public synchronized String returnResource(String coordinatorID,
+ String resourceID) {
+ String response;
+ boolean success = false;
+ String validation = validInput(resourceID, resourceNames.get(0), 1);
+ if (validation == null) {
+ if (resources.containsKey(resourceID)) {
+ Resource resource = resources.get(resourceID);
+ if (Objects.equals(resource.borrower, coordinatorID)) {
+ resource.borrower = null;
+ resource.borrowed = false;
+ response = "derms.Resource returned successfully.";
+ success = true;
+ if (!resource.requesters.isEmpty()) {
+ Requester r = resource.requesters.remove(resource.requesters.size() - 1);
+ requestResource(r.getCoordinatorID(), resourceID, r.getDuration());
+ }
+ } else {
+ response = "You are not the requester.";
+ }
+ } else {
+ response = "derms.Resource does not exist.";
+ success = false;
+ }
+ } else {
+ response = validation;
+ }
+ logOperation("returnResource", coordinatorID, resourceID, success, response);
+ return response;
+ }
+
+ @Override
+ public String swapResource(String coordinatorID,
+ String oldResourceID,
+ String oldResourceType,
+ String newResourceID,
+ String newResourceType) {
+ String response;
+ boolean success = false;
+ Map<String, Integer> others = getServerPortsFromCentralRepo();
+ others.remove(serverID);
+
+ String validation1 = validInput(oldResourceID, oldResourceType, 1);
+ if (validation1 != null) {
+ logOperation("swapResource", coordinatorID, oldResourceID, -1, false, validation1);
+ return validation1;
+ }
+ String validation2 = validInput(newResourceID, newResourceType, 1);
+ if (validation2 != null) {
+ logOperation("swapResource", coordinatorID, newResourceID, -1, false, validation2);
+ return validation2;
+ }
+
+ if (resources.containsKey(oldResourceID)) {
+ Resource resource = resources.get(oldResourceID);
+ if (resource.borrowed && Objects.equals(resource.borrower, coordinatorID)) {
+ if (others.containsKey(newResourceID.substring(0, 3))) {
+ try {
+ String s = sendMessage(String.format("REQUEST_RESOURCE %s %s %d", coordinatorID, newResourceID, resource.getDuration()), "localhost", others.get(newResourceID.substring(0, 3)));
+// System.out.println(s);
+ if (s.equals("derms.Resource requested successfully.")) {
+ returnResource(coordinatorID, oldResourceID);
+ response = "derms.Resource swapped successfully.";
+ success = true;
+ } else if(s.equals("Insufficient resource duration.")){
+ response = "Could not request newResource.";
+ }
+ else if(s.equals("derms.Resource does not exist.")) { System.out.println("NEW");
+ response = "derms.Resource does not exist.";
+ }
+ else{
+ response = s;}
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }else
+ {
+ response = "Incorrect server name";
+ }
+ } else {
+ response = "You are not the requester.";
+ }
+ } else { System.out.println("old");
+
+ response = "derms.Resource does not exist.";
+ }
+ logOperation("swapResource", coordinatorID, newResourceID, success, response);
+ return response;
+ }
+
+ private void logOperation(String operation, String resourceID, String resourceName, int duration, boolean success, String response) {
+ try (FileWriter writer = new FileWriter(serverID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + resourceID + " - " + resourceName + " - " + duration + " - " + (success ? "SUCCESS" : "FAILURE") + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void logOperation(String operation, String resourceID, int duration, boolean success, String response) {
+ try (FileWriter writer = new FileWriter(serverID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + resourceID + " - " + duration + " - " + (success ? "SUCCESS" : "FAILURE") + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void logOperation(String operation, String resourceName, boolean success, String response) {
+ try (FileWriter writer = new FileWriter(serverID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + resourceName + " - " + (success ? "SUCCESS" : "FAILURE") + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void logOperation(String operation, String coordinatorID, String resourceName, boolean success, String response) {
+ try (FileWriter writer = new FileWriter(serverID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + coordinatorID + " - " + resourceName + " - " + (success ? "SUCCESS" : "FAILURE") + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String validInput(String resourceID, String resourceName, int duration) {
+ if (resourceID.length() != 7 || !cities.contains(resourceID.substring(0, 3))) {
+ return "Invalid resource ID.";
+ }
+ try {
+ Integer.valueOf(resourceID.substring(3));
+ } catch (Exception e) {
+ return "Invalid resource ID.";
+ }
+ if (!resourceNames.contains(resourceName)) {
+ return "Invalid resource type.";
+ }
+ if (duration < 0) {
+ return "Invalid duration.";
+ }
+ return null;
+ }
+
+ class Resource {
+ private String resourceID;
+ private String resourceName;
+ private int duration;
+ private boolean borrowed = false;
+ private String borrower;
+ private List<Requester> requesters = new ArrayList<>();
+
+ public Resource(String resourceID, String resourceName, int duration) {
+ this.resourceID = resourceID;
+ this.resourceName = resourceName;
+ this.duration = duration;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public int getDuration() {
+ return duration;
+ }
+
+ public void setDuration(int duration) {
+ this.duration = duration;
+ }
+
+
+
+
+ @Override
+ public String toString() {
+ return String.format("derms.Resource{ID=%s, Name=%s, Duration=%d, Borrowed=%b, Borrower=%s}",
+ resourceID, resourceName, duration, borrowed, borrower);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/DERMSServerPublisher.java b/src/main/java/derms/replica1/DERMSServerPublisher.java
new file mode 100644
index 0000000..df175b6
--- /dev/null
+++ b/src/main/java/derms/replica1/DERMSServerPublisher.java
@@ -0,0 +1,16 @@
+package derms.replica1;
+
+import javax.xml.ws.Endpoint;
+
+public class DERMSServerPublisher {
+ public static void main(String[] args) {
+ try {
+ Endpoint.publish("http://localhost:8387/ws/derms", new DERMSServer("MTL"));
+// Endpoint.publish("http://localhost:8081/ws/derms", new DERMSServer("QUE"));
+// Endpoint.publish("http://localhost:8082/ws/derms", new DERMSServer("SHE"));
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ System.out.println("DERMS Web Service is published at http://localhost:8387/ws/derms");
+ }
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/Replica1.java b/src/main/java/derms/replica1/Replica1.java
new file mode 100644
index 0000000..10c0ce5
--- /dev/null
+++ b/src/main/java/derms/replica1/Replica1.java
@@ -0,0 +1,80 @@
+package derms.replica1;
+
+import derms.Replica;
+import derms.ReplicaManager;
+import derms.Request;
+import derms.Response;
+import derms.replica2.DermsLogger;
+import derms.util.ThreadPool;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.logging.Logger;
+
+public class Replica1 implements Replica {
+
+ private boolean alive = false;
+ private final ExecutorService pool;
+ private final Logger log;
+ private final InetAddress localAddr;
+ private final ResponderClient responderClient;
+ private final ReplicaManager replicaManager;
+
+ public Replica1(ReplicaManager replicaManager) {
+ this.replicaManager = replicaManager;
+ pool = Executors.newFixedThreadPool(5);
+ try {
+ localAddr = InetAddress.getLocalHost();
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+ responderClient = new ResponderClient("MTL");
+ try {
+ this.log = DermsLogger.getLogger(getClass());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public boolean isAlive() {
+ return alive;
+ }
+
+ @Override
+ public void startProcess() {
+ pool.execute(DERMSServer::new);
+ alive = true;
+ log.info(getClass().getSimpleName() + " started.");
+ log.config("Local address is "+localAddr.toString());
+ }
+
+ @Override
+ public void processRequest(Request request) {
+ String status = responderClient.addResource(
+ request.getResourceID(),
+ request.getResourceType(),
+ request.getDuration()
+ );
+ Response response = new Response(request.getSequenceNumber(), status);
+ log.info("Processed request " + request + "; response: " + response);
+ replicaManager.sendResponseToFE(response);
+ }
+
+ @Override
+ public void restart() {
+ log.info("Shutting down...");
+ ThreadPool.shutdown(pool, log);
+ alive = false;
+ log.info("Finished shutting down.");
+ startProcess();
+ }
+
+ @Override
+ public int getId() {
+ return 1;
+ }
+}
diff --git a/src/main/java/derms/replica1/Requester.java b/src/main/java/derms/replica1/Requester.java
new file mode 100644
index 0000000..a836aa3
--- /dev/null
+++ b/src/main/java/derms/replica1/Requester.java
@@ -0,0 +1,32 @@
+package derms.replica1;
+
+class Requester {
+ private String coordinatorID;
+ private int duration;
+
+ public Requester(String coordinatorID, int duration) {
+ this.coordinatorID = coordinatorID;
+ this.duration = duration;
+ }
+
+ public String getCoordinatorID() {
+ return coordinatorID;
+ }
+
+ public void setCoordinatorID(String coordinatorID) {
+ this.coordinatorID = coordinatorID;
+ }
+
+ public int getDuration() {
+ return duration;
+ }
+
+ public void setDuration(int duration) {
+ this.duration = duration;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("derms.Requester{CoordinatorID=%s, Duration=%d}", coordinatorID, duration);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/Resource.java b/src/main/java/derms/replica1/Resource.java
new file mode 100644
index 0000000..4d2f322
--- /dev/null
+++ b/src/main/java/derms/replica1/Resource.java
@@ -0,0 +1,48 @@
+package derms.replica1;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class Resource {
+ private String resourceID;
+ private String resourceName;
+ private int duration;
+ public boolean borrowed = false;
+ public String borrower;
+ public List<Requester> requesters = new LinkedList<>();
+
+ public Resource(String resourceID, String resourceName, int duration) {
+ this.resourceID = resourceID;
+ this.resourceName = resourceName;
+ this.duration = duration;
+ }
+
+ public String getResourceID() {
+ return resourceID;
+ }
+
+ public void setResourceID(String resourceID) {
+ this.resourceID = resourceID;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public int getDuration() {
+ return duration;
+ }
+
+ public void setDuration(int duration) {
+ this.duration = duration;
+ }
+
+ @Override
+ public String toString() {
+ return resourceID + " - " + resourceName + " - " + duration;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/ResponderClient.java b/src/main/java/derms/replica1/ResponderClient.java
new file mode 100644
index 0000000..c022fd3
--- /dev/null
+++ b/src/main/java/derms/replica1/ResponderClient.java
@@ -0,0 +1,106 @@
+package derms.replica1;
+
+import derms.replica1.jaxws.DERMSInterface;
+import derms.replica1.jaxws.DERMSServerService;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.util.Map;
+
+public class ResponderClient {
+
+ DERMSInterface server;
+ private String responderID;
+
+ public ResponderClient(String responderID) {
+ try {
+ this.responderID = responderID;
+ HashMap<String, String> servers = new HashMap<String, String>() {{
+ put("MTL", "http://localhost:8387/ws/derms?wsdl");
+ put("QUE", "http://localhost:8081/ws/derms?wsdl");
+ put("SHE", "http://localhost:8082/ws/derms?wsdl");
+ }};
+ URL url = new URL(servers.get(responderID.substring(0, 3)));
+ DERMSServerService service = new DERMSServerService(url);
+ server = service.getDERMSServerPort();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void respond() {
+ try {
+ String response = server.removeResource("MTL0012", 5);
+ System.out.println("Response: " + response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String[] args) {
+ ResponderClient client = new ResponderClient("Responder1");
+ client.respond();
+ }
+
+ public String addResource(String resourceID, String resourceName, int duration) {
+ try {
+ String response = server.addResource( resourceID, resourceName, duration);
+ System.out.println(response);
+ logOperation("addResource", resourceID, resourceName, duration, response);
+ return response;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void removeResource(String resourceID, int duration) {
+ try {
+ String response = server.removeResource(resourceID, duration);
+ System.out.println(response);
+ logOperation("removeResource", resourceID, duration, response);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public List<String> listResourceAvailability(String resourceName) {
+ try {
+ List<String> response = server.listResourceAvailability(resourceName);
+ logOperation("listResourceAvailability", resourceName, response.toString());
+ return response;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return Collections.emptyList();
+ }
+
+ private void logOperation(String operation, String resourceID, String resourceName, int duration, String response) {
+ try (FileWriter writer = new FileWriter(responderID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + resourceID + " - " + resourceName + " - " + duration + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void logOperation(String operation, String resourceID, int duration, String response) {
+ try (FileWriter writer = new FileWriter(responderID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + resourceID + " - " + duration + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void logOperation(String operation, String resourceName, String response) {
+ try (FileWriter writer = new FileWriter(responderID + "_log.txt", true)) {
+ writer.write(LocalDateTime.now() + " - " + operation + " - " + resourceName + " - " + response + "\n");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/derms/replica1/UDPUtilities.java b/src/main/java/derms/replica1/UDPUtilities.java
new file mode 100644
index 0000000..617f08a
--- /dev/null
+++ b/src/main/java/derms/replica1/UDPUtilities.java
@@ -0,0 +1,18 @@
+package derms.replica1;
+
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+
+public class UDPUtilities {
+ public static void sendMessage(String message, String host, int port) throws Exception {
+ DatagramSocket socket = new DatagramSocket();
+ InetAddress address = InetAddress.getByName(host);
+
+ byte[] buffer = message.getBytes();
+ DatagramPacket request = new DatagramPacket(buffer, buffer.length, address, port);
+
+ socket.send(request);
+ socket.close();
+ }
+}
diff --git a/src/main/java/derms/replica1/jaxws/AddResource.class b/src/main/java/derms/replica1/jaxws/AddResource.class
new file mode 100644
index 0000000..7e57641
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/AddResource.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/AddResource.java b/src/main/java/derms/replica1/jaxws/AddResource.java
new file mode 100644
index 0000000..d768458
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/AddResource.java
@@ -0,0 +1,106 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for addResource complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="addResource">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="resourceID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="resourceName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="duration" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "addResource", propOrder = {
+ "resourceID",
+ "resourceName",
+ "duration"
+})
+public class AddResource {
+
+ protected String resourceID;
+ protected String resourceName;
+ protected int duration;
+
+ /**
+ * Gets the value of the resourceID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResourceID() {
+ return resourceID;
+ }
+
+ /**
+ * Sets the value of the resourceID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResourceID(String value) {
+ this.resourceID = value;
+ }
+
+ /**
+ * Gets the value of the resourceName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /**
+ * Sets the value of the resourceName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResourceName(String value) {
+ this.resourceName = value;
+ }
+
+ /**
+ * Gets the value of the duration property.
+ *
+ */
+ public int getDuration() {
+ return duration;
+ }
+
+ /**
+ * Sets the value of the duration property.
+ *
+ */
+ public void setDuration(int value) {
+ this.duration = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/AddResourceResponse.class b/src/main/java/derms/replica1/jaxws/AddResourceResponse.class
new file mode 100644
index 0000000..1744e33
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/AddResourceResponse.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/AddResourceResponse.java b/src/main/java/derms/replica1/jaxws/AddResourceResponse.java
new file mode 100644
index 0000000..cff0c84
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/AddResourceResponse.java
@@ -0,0 +1,62 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for addResourceResponse complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="addResourceResponse">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "addResourceResponse", propOrder = {
+ "_return"
+})
+public class AddResourceResponse {
+
+ @XmlElement(name = "return")
+ protected String _return;
+
+ /**
+ * Gets the value of the return property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getReturn() {
+ return _return;
+ }
+
+ /**
+ * Sets the value of the return property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setReturn(String value) {
+ this._return = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/DERMSInterface.class b/src/main/java/derms/replica1/jaxws/DERMSInterface.class
new file mode 100644
index 0000000..ac825cb
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/DERMSInterface.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/DERMSInterface.java b/src/main/java/derms/replica1/jaxws/DERMSInterface.java
new file mode 100644
index 0000000..cdb40f4
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/DERMSInterface.java
@@ -0,0 +1,166 @@
+
+package derms.replica1.jaxws;
+
+import java.util.List;
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.ws.Action;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.ResponseWrapper;
+
+
+/**
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.2.9-b130926.1035
+ * Generated source version: 2.2
+ *
+ */
+@WebService(name = "DERMSInterface", targetNamespace = "http://replica1.derms/")
+@XmlSeeAlso({
+ ObjectFactory.class
+})
+public interface DERMSInterface {
+
+
+ /**
+ *
+ * @param duration
+ * @param resourceID
+ * @param resourceName
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "")
+ @RequestWrapper(localName = "addResource", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.AddResource")
+ @ResponseWrapper(localName = "addResourceResponse", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.AddResourceResponse")
+ @Action(input = "http://replica1.derms/DERMSInterface/addResourceRequest", output = "http://replica1.derms/DERMSInterface/addResourceResponse")
+ public String addResource(
+ @WebParam(name = "resourceID", targetNamespace = "")
+ String resourceID,
+ @WebParam(name = "resourceName", targetNamespace = "")
+ String resourceName,
+ @WebParam(name = "duration", targetNamespace = "")
+ int duration);
+
+ /**
+ *
+ * @param duration
+ * @param resourceID
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "")
+ @RequestWrapper(localName = "removeResource", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.RemoveResource")
+ @ResponseWrapper(localName = "removeResourceResponse", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.RemoveResourceResponse")
+ @Action(input = "http://replica1.derms/DERMSInterface/removeResourceRequest", output = "http://replica1.derms/DERMSInterface/removeResourceResponse")
+ public String removeResource(
+ @WebParam(name = "resourceID", targetNamespace = "")
+ String resourceID,
+ @WebParam(name = "duration", targetNamespace = "")
+ int duration);
+
+ /**
+ *
+ * @param resourceName
+ * @return
+ * returns java.util.List<java.lang.String>
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "")
+ @RequestWrapper(localName = "listResourceAvailability", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.ListResourceAvailability")
+ @ResponseWrapper(localName = "listResourceAvailabilityResponse", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.ListResourceAvailabilityResponse")
+ @Action(input = "http://replica1.derms/DERMSInterface/listResourceAvailabilityRequest", output = "http://replica1.derms/DERMSInterface/listResourceAvailabilityResponse")
+ public List<String> listResourceAvailability(
+ @WebParam(name = "resourceName", targetNamespace = "")
+ String resourceName);
+
+ /**
+ *
+ * @param duration
+ * @param resourceID
+ * @param coordinatorID
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "")
+ @RequestWrapper(localName = "requestResource", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.RequestResource")
+ @ResponseWrapper(localName = "requestResourceResponse", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.RequestResourceResponse")
+ @Action(input = "http://replica1.derms/DERMSInterface/requestResourceRequest", output = "http://replica1.derms/DERMSInterface/requestResourceResponse")
+ public String requestResource(
+ @WebParam(name = "coordinatorID", targetNamespace = "")
+ String coordinatorID,
+ @WebParam(name = "resourceID", targetNamespace = "")
+ String resourceID,
+ @WebParam(name = "duration", targetNamespace = "")
+ int duration);
+
+ /**
+ *
+ * @param resourceID
+ * @param coordinatorID
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "")
+ @RequestWrapper(localName = "returnResource", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.ReturnResource")
+ @ResponseWrapper(localName = "returnResourceResponse", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.ReturnResourceResponse")
+ @Action(input = "http://replica1.derms/DERMSInterface/returnResourceRequest", output = "http://replica1.derms/DERMSInterface/returnResourceResponse")
+ public String returnResource(
+ @WebParam(name = "coordinatorID", targetNamespace = "")
+ String coordinatorID,
+ @WebParam(name = "resourceID", targetNamespace = "")
+ String resourceID);
+
+ /**
+ *
+ * @param oldResourceID
+ * @param newResourceID
+ * @param coordinatorID
+ * @param oldResourceType
+ * @param newResourceType
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "")
+ @RequestWrapper(localName = "swapResource", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.SwapResource")
+ @ResponseWrapper(localName = "swapResourceResponse", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.SwapResourceResponse")
+ @Action(input = "http://replica1.derms/DERMSInterface/swapResourceRequest", output = "http://replica1.derms/DERMSInterface/swapResourceResponse")
+ public String swapResource(
+ @WebParam(name = "coordinatorID", targetNamespace = "")
+ String coordinatorID,
+ @WebParam(name = "oldResourceID", targetNamespace = "")
+ String oldResourceID,
+ @WebParam(name = "oldResourceType", targetNamespace = "")
+ String oldResourceType,
+ @WebParam(name = "newResourceID", targetNamespace = "")
+ String newResourceID,
+ @WebParam(name = "newResourceType", targetNamespace = "")
+ String newResourceType);
+
+ /**
+ *
+ * @param coordinatorID
+ * @param resourceName
+ * @return
+ * returns java.util.List<java.lang.String>
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "")
+ @RequestWrapper(localName = "findResource", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.FindResource")
+ @ResponseWrapper(localName = "findResourceResponse", targetNamespace = "http://replica1.derms/", className = "derms.replica1.jaxws.FindResourceResponse")
+ @Action(input = "http://replica1.derms/DERMSInterface/findResourceRequest", output = "http://replica1.derms/DERMSInterface/findResourceResponse")
+ public List<String> findResource(
+ @WebParam(name = "coordinatorID", targetNamespace = "")
+ String coordinatorID,
+ @WebParam(name = "resourceName", targetNamespace = "")
+ String resourceName);
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/DERMSServerService.class b/src/main/java/derms/replica1/jaxws/DERMSServerService.class
new file mode 100644
index 0000000..5896bfb
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/DERMSServerService.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/DERMSServerService.java b/src/main/java/derms/replica1/jaxws/DERMSServerService.java
new file mode 100644
index 0000000..2343bdf
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/DERMSServerService.java
@@ -0,0 +1,94 @@
+
+package derms.replica1.jaxws;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebEndpoint;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceFeature;
+
+
+/**
+ * This class was generated by the JAX-WS RI.
+ * JAX-WS RI 2.2.9-b130926.1035
+ * Generated source version: 2.2
+ *
+ */
+@WebServiceClient(name = "DERMSServerService", targetNamespace = "http://replica1.derms/", wsdlLocation = "http://localhost:8387/ws/derms?wsdl")
+public class DERMSServerService
+ extends Service
+{
+
+ private final static URL DERMSSERVERSERVICE_WSDL_LOCATION;
+ private final static WebServiceException DERMSSERVERSERVICE_EXCEPTION;
+ private final static QName DERMSSERVERSERVICE_QNAME = new QName("http://replica1.derms/", "DERMSServerService");
+
+ static {
+ URL url = null;
+ WebServiceException e = null;
+ try {
+ url = new URL("http://localhost:8387/ws/derms?wsdl");
+ } catch (MalformedURLException ex) {
+ e = new WebServiceException(ex);
+ }
+ DERMSSERVERSERVICE_WSDL_LOCATION = url;
+ DERMSSERVERSERVICE_EXCEPTION = e;
+ }
+
+ public DERMSServerService() {
+ super(__getWsdlLocation(), DERMSSERVERSERVICE_QNAME);
+ }
+
+ public DERMSServerService(WebServiceFeature... features) {
+ super(__getWsdlLocation(), DERMSSERVERSERVICE_QNAME, features);
+ }
+
+ public DERMSServerService(URL wsdlLocation) {
+ super(wsdlLocation, DERMSSERVERSERVICE_QNAME);
+ }
+
+ public DERMSServerService(URL wsdlLocation, WebServiceFeature... features) {
+ super(wsdlLocation, DERMSSERVERSERVICE_QNAME, features);
+ }
+
+ public DERMSServerService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+
+ public DERMSServerService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
+ super(wsdlLocation, serviceName, features);
+ }
+
+ /**
+ *
+ * @return
+ * returns DERMSInterface
+ */
+ @WebEndpoint(name = "DERMSServerPort")
+ public DERMSInterface getDERMSServerPort() {
+ return super.getPort(new QName("http://replica1.derms/", "DERMSServerPort"), DERMSInterface.class);
+ }
+
+ /**
+ *
+ * @param features
+ * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
+ * @return
+ * returns DERMSInterface
+ */
+ @WebEndpoint(name = "DERMSServerPort")
+ public DERMSInterface getDERMSServerPort(WebServiceFeature... features) {
+ return super.getPort(new QName("http://replica1.derms/", "DERMSServerPort"), DERMSInterface.class, features);
+ }
+
+ private static URL __getWsdlLocation() {
+ if (DERMSSERVERSERVICE_EXCEPTION!= null) {
+ throw DERMSSERVERSERVICE_EXCEPTION;
+ }
+ return DERMSSERVERSERVICE_WSDL_LOCATION;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/FindResource.class b/src/main/java/derms/replica1/jaxws/FindResource.class
new file mode 100644
index 0000000..73c6cf2
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/FindResource.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/FindResource.java b/src/main/java/derms/replica1/jaxws/FindResource.java
new file mode 100644
index 0000000..f5751b6
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/FindResource.java
@@ -0,0 +1,87 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for findResource complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="findResource">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="coordinatorID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="resourceName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "findResource", propOrder = {
+ "coordinatorID",
+ "resourceName"
+})
+public class FindResource {
+
+ protected String coordinatorID;
+ protected String resourceName;
+
+ /**
+ * Gets the value of the coordinatorID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCoordinatorID() {
+ return coordinatorID;
+ }
+
+ /**
+ * Sets the value of the coordinatorID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCoordinatorID(String value) {
+ this.coordinatorID = value;
+ }
+
+ /**
+ * Gets the value of the resourceName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /**
+ * Sets the value of the resourceName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResourceName(String value) {
+ this.resourceName = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/FindResourceResponse.class b/src/main/java/derms/replica1/jaxws/FindResourceResponse.class
new file mode 100644
index 0000000..374b089
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/FindResourceResponse.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/FindResourceResponse.java b/src/main/java/derms/replica1/jaxws/FindResourceResponse.java
new file mode 100644
index 0000000..93c22f6
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/FindResourceResponse.java
@@ -0,0 +1,69 @@
+
+package derms.replica1.jaxws;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for findResourceResponse complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="findResourceResponse">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "findResourceResponse", propOrder = {
+ "_return"
+})
+public class FindResourceResponse {
+
+ @XmlElement(name = "return")
+ protected List<String> _return;
+
+ /**
+ * Gets the value of the return property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the return property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getReturn().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getReturn() {
+ if (_return == null) {
+ _return = new ArrayList<String>();
+ }
+ return this._return;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/ListResourceAvailability.class b/src/main/java/derms/replica1/jaxws/ListResourceAvailability.class
new file mode 100644
index 0000000..7e46386
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ListResourceAvailability.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/ListResourceAvailability.java b/src/main/java/derms/replica1/jaxws/ListResourceAvailability.java
new file mode 100644
index 0000000..638e6bd
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ListResourceAvailability.java
@@ -0,0 +1,60 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for listResourceAvailability complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="listResourceAvailability">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="resourceName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "listResourceAvailability", propOrder = {
+ "resourceName"
+})
+public class ListResourceAvailability {
+
+ protected String resourceName;
+
+ /**
+ * Gets the value of the resourceName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /**
+ * Sets the value of the resourceName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResourceName(String value) {
+ this.resourceName = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.class b/src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.class
new file mode 100644
index 0000000..65f9d9b
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.java b/src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.java
new file mode 100644
index 0000000..1653071
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ListResourceAvailabilityResponse.java
@@ -0,0 +1,69 @@
+
+package derms.replica1.jaxws;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for listResourceAvailabilityResponse complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="listResourceAvailabilityResponse">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "listResourceAvailabilityResponse", propOrder = {
+ "_return"
+})
+public class ListResourceAvailabilityResponse {
+
+ @XmlElement(name = "return")
+ protected List<String> _return;
+
+ /**
+ * Gets the value of the return property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the return property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getReturn().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getReturn() {
+ if (_return == null) {
+ _return = new ArrayList<String>();
+ }
+ return this._return;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/ObjectFactory.class b/src/main/java/derms/replica1/jaxws/ObjectFactory.class
new file mode 100644
index 0000000..11aa84e
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ObjectFactory.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/ObjectFactory.java b/src/main/java/derms/replica1/jaxws/ObjectFactory.java
new file mode 100644
index 0000000..35e35e7
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ObjectFactory.java
@@ -0,0 +1,287 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the derms.replica1.jaxws package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _RemoveResourceResponse_QNAME = new QName("http://replica1.derms/", "removeResourceResponse");
+ private final static QName _SwapResourceResponse_QNAME = new QName("http://replica1.derms/", "swapResourceResponse");
+ private final static QName _AddResource_QNAME = new QName("http://replica1.derms/", "addResource");
+ private final static QName _ReturnResourceResponse_QNAME = new QName("http://replica1.derms/", "returnResourceResponse");
+ private final static QName _RequestResourceResponse_QNAME = new QName("http://replica1.derms/", "requestResourceResponse");
+ private final static QName _ListResourceAvailability_QNAME = new QName("http://replica1.derms/", "listResourceAvailability");
+ private final static QName _RemoveResource_QNAME = new QName("http://replica1.derms/", "removeResource");
+ private final static QName _AddResourceResponse_QNAME = new QName("http://replica1.derms/", "addResourceResponse");
+ private final static QName _FindResourceResponse_QNAME = new QName("http://replica1.derms/", "findResourceResponse");
+ private final static QName _SwapResource_QNAME = new QName("http://replica1.derms/", "swapResource");
+ private final static QName _ListResourceAvailabilityResponse_QNAME = new QName("http://replica1.derms/", "listResourceAvailabilityResponse");
+ private final static QName _FindResource_QNAME = new QName("http://replica1.derms/", "findResource");
+ private final static QName _ReturnResource_QNAME = new QName("http://replica1.derms/", "returnResource");
+ private final static QName _RequestResource_QNAME = new QName("http://replica1.derms/", "requestResource");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: derms.replica1.jaxws
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link RequestResource }
+ *
+ */
+ public RequestResource createRequestResource() {
+ return new RequestResource();
+ }
+
+ /**
+ * Create an instance of {@link FindResource }
+ *
+ */
+ public FindResource createFindResource() {
+ return new FindResource();
+ }
+
+ /**
+ * Create an instance of {@link ReturnResource }
+ *
+ */
+ public ReturnResource createReturnResource() {
+ return new ReturnResource();
+ }
+
+ /**
+ * Create an instance of {@link ListResourceAvailabilityResponse }
+ *
+ */
+ public ListResourceAvailabilityResponse createListResourceAvailabilityResponse() {
+ return new ListResourceAvailabilityResponse();
+ }
+
+ /**
+ * Create an instance of {@link SwapResource }
+ *
+ */
+ public SwapResource createSwapResource() {
+ return new SwapResource();
+ }
+
+ /**
+ * Create an instance of {@link FindResourceResponse }
+ *
+ */
+ public FindResourceResponse createFindResourceResponse() {
+ return new FindResourceResponse();
+ }
+
+ /**
+ * Create an instance of {@link RemoveResource }
+ *
+ */
+ public RemoveResource createRemoveResource() {
+ return new RemoveResource();
+ }
+
+ /**
+ * Create an instance of {@link AddResourceResponse }
+ *
+ */
+ public AddResourceResponse createAddResourceResponse() {
+ return new AddResourceResponse();
+ }
+
+ /**
+ * Create an instance of {@link ListResourceAvailability }
+ *
+ */
+ public ListResourceAvailability createListResourceAvailability() {
+ return new ListResourceAvailability();
+ }
+
+ /**
+ * Create an instance of {@link AddResource }
+ *
+ */
+ public AddResource createAddResource() {
+ return new AddResource();
+ }
+
+ /**
+ * Create an instance of {@link ReturnResourceResponse }
+ *
+ */
+ public ReturnResourceResponse createReturnResourceResponse() {
+ return new ReturnResourceResponse();
+ }
+
+ /**
+ * Create an instance of {@link RequestResourceResponse }
+ *
+ */
+ public RequestResourceResponse createRequestResourceResponse() {
+ return new RequestResourceResponse();
+ }
+
+ /**
+ * Create an instance of {@link SwapResourceResponse }
+ *
+ */
+ public SwapResourceResponse createSwapResourceResponse() {
+ return new SwapResourceResponse();
+ }
+
+ /**
+ * Create an instance of {@link RemoveResourceResponse }
+ *
+ */
+ public RemoveResourceResponse createRemoveResourceResponse() {
+ return new RemoveResourceResponse();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link RemoveResourceResponse }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "removeResourceResponse")
+ public JAXBElement<RemoveResourceResponse> createRemoveResourceResponse(RemoveResourceResponse value) {
+ return new JAXBElement<RemoveResourceResponse>(_RemoveResourceResponse_QNAME, RemoveResourceResponse.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SwapResourceResponse }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "swapResourceResponse")
+ public JAXBElement<SwapResourceResponse> createSwapResourceResponse(SwapResourceResponse value) {
+ return new JAXBElement<SwapResourceResponse>(_SwapResourceResponse_QNAME, SwapResourceResponse.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link AddResource }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "addResource")
+ public JAXBElement<AddResource> createAddResource(AddResource value) {
+ return new JAXBElement<AddResource>(_AddResource_QNAME, AddResource.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ReturnResourceResponse }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "returnResourceResponse")
+ public JAXBElement<ReturnResourceResponse> createReturnResourceResponse(ReturnResourceResponse value) {
+ return new JAXBElement<ReturnResourceResponse>(_ReturnResourceResponse_QNAME, ReturnResourceResponse.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link RequestResourceResponse }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "requestResourceResponse")
+ public JAXBElement<RequestResourceResponse> createRequestResourceResponse(RequestResourceResponse value) {
+ return new JAXBElement<RequestResourceResponse>(_RequestResourceResponse_QNAME, RequestResourceResponse.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ListResourceAvailability }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "listResourceAvailability")
+ public JAXBElement<ListResourceAvailability> createListResourceAvailability(ListResourceAvailability value) {
+ return new JAXBElement<ListResourceAvailability>(_ListResourceAvailability_QNAME, ListResourceAvailability.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link RemoveResource }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "removeResource")
+ public JAXBElement<RemoveResource> createRemoveResource(RemoveResource value) {
+ return new JAXBElement<RemoveResource>(_RemoveResource_QNAME, RemoveResource.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link AddResourceResponse }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "addResourceResponse")
+ public JAXBElement<AddResourceResponse> createAddResourceResponse(AddResourceResponse value) {
+ return new JAXBElement<AddResourceResponse>(_AddResourceResponse_QNAME, AddResourceResponse.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link FindResourceResponse }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "findResourceResponse")
+ public JAXBElement<FindResourceResponse> createFindResourceResponse(FindResourceResponse value) {
+ return new JAXBElement<FindResourceResponse>(_FindResourceResponse_QNAME, FindResourceResponse.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link SwapResource }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "swapResource")
+ public JAXBElement<SwapResource> createSwapResource(SwapResource value) {
+ return new JAXBElement<SwapResource>(_SwapResource_QNAME, SwapResource.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ListResourceAvailabilityResponse }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "listResourceAvailabilityResponse")
+ public JAXBElement<ListResourceAvailabilityResponse> createListResourceAvailabilityResponse(ListResourceAvailabilityResponse value) {
+ return new JAXBElement<ListResourceAvailabilityResponse>(_ListResourceAvailabilityResponse_QNAME, ListResourceAvailabilityResponse.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link FindResource }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "findResource")
+ public JAXBElement<FindResource> createFindResource(FindResource value) {
+ return new JAXBElement<FindResource>(_FindResource_QNAME, FindResource.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link ReturnResource }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "returnResource")
+ public JAXBElement<ReturnResource> createReturnResource(ReturnResource value) {
+ return new JAXBElement<ReturnResource>(_ReturnResource_QNAME, ReturnResource.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link RequestResource }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://replica1.derms/", name = "requestResource")
+ public JAXBElement<RequestResource> createRequestResource(RequestResource value) {
+ return new JAXBElement<RequestResource>(_RequestResource_QNAME, RequestResource.class, null, value);
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/RemoveResource.class b/src/main/java/derms/replica1/jaxws/RemoveResource.class
new file mode 100644
index 0000000..9d88d4f
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RemoveResource.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/RemoveResource.java b/src/main/java/derms/replica1/jaxws/RemoveResource.java
new file mode 100644
index 0000000..95a0798
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RemoveResource.java
@@ -0,0 +1,79 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for removeResource complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="removeResource">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="resourceID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="duration" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "removeResource", propOrder = {
+ "resourceID",
+ "duration"
+})
+public class RemoveResource {
+
+ protected String resourceID;
+ protected int duration;
+
+ /**
+ * Gets the value of the resourceID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResourceID() {
+ return resourceID;
+ }
+
+ /**
+ * Sets the value of the resourceID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResourceID(String value) {
+ this.resourceID = value;
+ }
+
+ /**
+ * Gets the value of the duration property.
+ *
+ */
+ public int getDuration() {
+ return duration;
+ }
+
+ /**
+ * Sets the value of the duration property.
+ *
+ */
+ public void setDuration(int value) {
+ this.duration = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/RemoveResourceResponse.class b/src/main/java/derms/replica1/jaxws/RemoveResourceResponse.class
new file mode 100644
index 0000000..054300e
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RemoveResourceResponse.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/RemoveResourceResponse.java b/src/main/java/derms/replica1/jaxws/RemoveResourceResponse.java
new file mode 100644
index 0000000..b7f038e
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RemoveResourceResponse.java
@@ -0,0 +1,62 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for removeResourceResponse complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="removeResourceResponse">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "removeResourceResponse", propOrder = {
+ "_return"
+})
+public class RemoveResourceResponse {
+
+ @XmlElement(name = "return")
+ protected String _return;
+
+ /**
+ * Gets the value of the return property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getReturn() {
+ return _return;
+ }
+
+ /**
+ * Sets the value of the return property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setReturn(String value) {
+ this._return = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/RequestResource.class b/src/main/java/derms/replica1/jaxws/RequestResource.class
new file mode 100644
index 0000000..eedd065
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RequestResource.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/RequestResource.java b/src/main/java/derms/replica1/jaxws/RequestResource.java
new file mode 100644
index 0000000..19f2ea7
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RequestResource.java
@@ -0,0 +1,106 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for requestResource complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="requestResource">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="coordinatorID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="resourceID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="duration" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "requestResource", propOrder = {
+ "coordinatorID",
+ "resourceID",
+ "duration"
+})
+public class RequestResource {
+
+ protected String coordinatorID;
+ protected String resourceID;
+ protected int duration;
+
+ /**
+ * Gets the value of the coordinatorID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCoordinatorID() {
+ return coordinatorID;
+ }
+
+ /**
+ * Sets the value of the coordinatorID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCoordinatorID(String value) {
+ this.coordinatorID = value;
+ }
+
+ /**
+ * Gets the value of the resourceID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResourceID() {
+ return resourceID;
+ }
+
+ /**
+ * Sets the value of the resourceID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResourceID(String value) {
+ this.resourceID = value;
+ }
+
+ /**
+ * Gets the value of the duration property.
+ *
+ */
+ public int getDuration() {
+ return duration;
+ }
+
+ /**
+ * Sets the value of the duration property.
+ *
+ */
+ public void setDuration(int value) {
+ this.duration = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/RequestResourceResponse.class b/src/main/java/derms/replica1/jaxws/RequestResourceResponse.class
new file mode 100644
index 0000000..ebfa3a3
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RequestResourceResponse.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/RequestResourceResponse.java b/src/main/java/derms/replica1/jaxws/RequestResourceResponse.java
new file mode 100644
index 0000000..035214b
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/RequestResourceResponse.java
@@ -0,0 +1,62 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for requestResourceResponse complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="requestResourceResponse">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "requestResourceResponse", propOrder = {
+ "_return"
+})
+public class RequestResourceResponse {
+
+ @XmlElement(name = "return")
+ protected String _return;
+
+ /**
+ * Gets the value of the return property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getReturn() {
+ return _return;
+ }
+
+ /**
+ * Sets the value of the return property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setReturn(String value) {
+ this._return = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/ReturnResource.class b/src/main/java/derms/replica1/jaxws/ReturnResource.class
new file mode 100644
index 0000000..fee143d
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ReturnResource.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/ReturnResource.java b/src/main/java/derms/replica1/jaxws/ReturnResource.java
new file mode 100644
index 0000000..577bee1
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ReturnResource.java
@@ -0,0 +1,87 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for returnResource complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="returnResource">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="coordinatorID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="resourceID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "returnResource", propOrder = {
+ "coordinatorID",
+ "resourceID"
+})
+public class ReturnResource {
+
+ protected String coordinatorID;
+ protected String resourceID;
+
+ /**
+ * Gets the value of the coordinatorID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCoordinatorID() {
+ return coordinatorID;
+ }
+
+ /**
+ * Sets the value of the coordinatorID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCoordinatorID(String value) {
+ this.coordinatorID = value;
+ }
+
+ /**
+ * Gets the value of the resourceID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getResourceID() {
+ return resourceID;
+ }
+
+ /**
+ * Sets the value of the resourceID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setResourceID(String value) {
+ this.resourceID = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/ReturnResourceResponse.class b/src/main/java/derms/replica1/jaxws/ReturnResourceResponse.class
new file mode 100644
index 0000000..f07c35e
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ReturnResourceResponse.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/ReturnResourceResponse.java b/src/main/java/derms/replica1/jaxws/ReturnResourceResponse.java
new file mode 100644
index 0000000..3272536
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/ReturnResourceResponse.java
@@ -0,0 +1,62 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for returnResourceResponse complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="returnResourceResponse">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "returnResourceResponse", propOrder = {
+ "_return"
+})
+public class ReturnResourceResponse {
+
+ @XmlElement(name = "return")
+ protected String _return;
+
+ /**
+ * Gets the value of the return property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getReturn() {
+ return _return;
+ }
+
+ /**
+ * Sets the value of the return property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setReturn(String value) {
+ this._return = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/SwapResource.class b/src/main/java/derms/replica1/jaxws/SwapResource.class
new file mode 100644
index 0000000..4523489
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/SwapResource.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/SwapResource.java b/src/main/java/derms/replica1/jaxws/SwapResource.java
new file mode 100644
index 0000000..e61f8f7
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/SwapResource.java
@@ -0,0 +1,168 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for swapResource complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="swapResource">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="coordinatorID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="oldResourceID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="oldResourceType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="newResourceID" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;element name="newResourceType" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "swapResource", propOrder = {
+ "coordinatorID",
+ "oldResourceID",
+ "oldResourceType",
+ "newResourceID",
+ "newResourceType"
+})
+public class SwapResource {
+
+ protected String coordinatorID;
+ protected String oldResourceID;
+ protected String oldResourceType;
+ protected String newResourceID;
+ protected String newResourceType;
+
+ /**
+ * Gets the value of the coordinatorID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getCoordinatorID() {
+ return coordinatorID;
+ }
+
+ /**
+ * Sets the value of the coordinatorID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setCoordinatorID(String value) {
+ this.coordinatorID = value;
+ }
+
+ /**
+ * Gets the value of the oldResourceID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getOldResourceID() {
+ return oldResourceID;
+ }
+
+ /**
+ * Sets the value of the oldResourceID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setOldResourceID(String value) {
+ this.oldResourceID = value;
+ }
+
+ /**
+ * Gets the value of the oldResourceType property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getOldResourceType() {
+ return oldResourceType;
+ }
+
+ /**
+ * Sets the value of the oldResourceType property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setOldResourceType(String value) {
+ this.oldResourceType = value;
+ }
+
+ /**
+ * Gets the value of the newResourceID property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getNewResourceID() {
+ return newResourceID;
+ }
+
+ /**
+ * Sets the value of the newResourceID property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setNewResourceID(String value) {
+ this.newResourceID = value;
+ }
+
+ /**
+ * Gets the value of the newResourceType property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getNewResourceType() {
+ return newResourceType;
+ }
+
+ /**
+ * Sets the value of the newResourceType property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setNewResourceType(String value) {
+ this.newResourceType = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/SwapResourceResponse.class b/src/main/java/derms/replica1/jaxws/SwapResourceResponse.class
new file mode 100644
index 0000000..036f232
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/SwapResourceResponse.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/SwapResourceResponse.java b/src/main/java/derms/replica1/jaxws/SwapResourceResponse.java
new file mode 100644
index 0000000..5815863
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/SwapResourceResponse.java
@@ -0,0 +1,62 @@
+
+package derms.replica1.jaxws;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for swapResourceResponse complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType name="swapResourceResponse">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "swapResourceResponse", propOrder = {
+ "_return"
+})
+public class SwapResourceResponse {
+
+ @XmlElement(name = "return")
+ protected String _return;
+
+ /**
+ * Gets the value of the return property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getReturn() {
+ return _return;
+ }
+
+ /**
+ * Sets the value of the return property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setReturn(String value) {
+ this._return = value;
+ }
+
+}
diff --git a/src/main/java/derms/replica1/jaxws/package-info.class b/src/main/java/derms/replica1/jaxws/package-info.class
new file mode 100644
index 0000000..e068a5e
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/package-info.class
Binary files differ
diff --git a/src/main/java/derms/replica1/jaxws/package-info.java b/src/main/java/derms/replica1/jaxws/package-info.java
new file mode 100644
index 0000000..59b82f4
--- /dev/null
+++ b/src/main/java/derms/replica1/jaxws/package-info.java
@@ -0,0 +1,2 @@
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://replica1.derms/")
+package derms.replica1.jaxws;
diff --git a/src/main/java/derms/replica2/DermsLogger.java b/src/main/java/derms/replica2/DermsLogger.java
index 3e031f7..48e6751 100644
--- a/src/main/java/derms/replica2/DermsLogger.java
+++ b/src/main/java/derms/replica2/DermsLogger.java
@@ -6,12 +6,12 @@ import java.util.logging.Handler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
-class DermsLogger {
+public class DermsLogger {
static final String logFile = "server.log";
private static Logger log = null;
- static Logger getLogger(Class clazz) throws IOException {
+ public static Logger getLogger(Class clazz) throws IOException {
if (log == null) {
log = Logger.getLogger(clazz.getName());
Handler fileHandler = new FileHandler(logFile);