diff options
| author | ShazaAli <shazamamdouh@aucegypt.edu> | 2024-12-01 08:23:40 -0500 |
|---|---|---|
| committer | ShazaAli <shazamamdouh@aucegypt.edu> | 2024-12-01 08:23:40 -0500 |
| commit | 53bd785304f4ecb62f46e19f02183a858aebe027 (patch) | |
| tree | adbdb888329fab8f406e6eed6c9cb88508d9d1bd /src/main/java/derms/replica2 | |
| parent | 66f256b05c7daa7c4cd20f20758b8413a9329500 (diff) | |
| download | soen423-53bd785304f4ecb62f46e19f02183a858aebe027.zip | |
running all. error comm between FE Replica
Diffstat (limited to 'src/main/java/derms/replica2')
| -rw-r--r-- | src/main/java/derms/replica2/City.java | 4 | ||||
| -rw-r--r-- | src/main/java/derms/replica2/Replica2.java | 6 | ||||
| -rw-r--r-- | src/main/java/derms/replica2/Resource.java | 2 | ||||
| -rw-r--r-- | src/main/java/derms/replica2/ReturnResource.java | 2 | ||||
| -rw-r--r-- | src/main/java/derms/replica2/SwapResource.java | 2 |
5 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/derms/replica2/City.java b/src/main/java/derms/replica2/City.java index 74535ae..a5a2f4c 100644 --- a/src/main/java/derms/replica2/City.java +++ b/src/main/java/derms/replica2/City.java @@ -2,7 +2,7 @@ package derms.replica2; import java.io.Serializable; -class City implements Serializable { +public class City implements Serializable { static final int codeLen = 3; private String code; @@ -13,7 +13,7 @@ class City implements Serializable { this.code = code; } - City() { + public City() { this("XXX"); } diff --git a/src/main/java/derms/replica2/Replica2.java b/src/main/java/derms/replica2/Replica2.java index 25609cc..666ee1b 100644 --- a/src/main/java/derms/replica2/Replica2.java +++ b/src/main/java/derms/replica2/Replica2.java @@ -1,6 +1,7 @@ package derms.replica2; import derms.Replica; +import derms.ReplicaManager; import derms.Request; import derms.Response; import sun.reflect.generics.reflectiveObjects.NotImplementedException; @@ -23,14 +24,15 @@ public class Replica2 implements Replica { private final ResponderServer responderServer; private final CoordinatorServer coordinatorServer; private boolean alive; + private final ReplicaManager replicaManager; - public Replica2(City city) throws IOException { + public Replica2(City city, ReplicaManager replicaManager) throws IOException { this.city = city; this.localAddr = InetAddress.getLocalHost(); this.resources = new Resources(); this.servers = new Servers(); this.log = DermsLogger.getLogger(getClass()); - + this.replicaManager = replicaManager; try { this.responderServer = new ResponderServer(city, resources, servers); } catch (IOException e) { diff --git a/src/main/java/derms/replica2/Resource.java b/src/main/java/derms/replica2/Resource.java index 31d40bc..404cfb0 100644 --- a/src/main/java/derms/replica2/Resource.java +++ b/src/main/java/derms/replica2/Resource.java @@ -20,7 +20,7 @@ class Resource implements Serializable { } Resource(ResourceID id, ResourceType type, int duration) { - this(id, type, duration, false, new CoordinatorID(), -1); + this(id, type, duration, false, new CoordinatorID("XXX", (short) 1), -1); } Resource() { diff --git a/src/main/java/derms/replica2/ReturnResource.java b/src/main/java/derms/replica2/ReturnResource.java index 6c42b8a..6adac50 100644 --- a/src/main/java/derms/replica2/ReturnResource.java +++ b/src/main/java/derms/replica2/ReturnResource.java @@ -169,7 +169,7 @@ class ReturnResource { request.resourceID+" is not borrowed by "+request.coordinatorID); } resource.isBorrowed = false; - resource.borrower = new CoordinatorID(); + resource.borrower = request.coordinatorID; resource.borrowDuration = -1; return new Response(Response.Status.SUCCESS, request.coordinatorID+" successfully returned "+resource.id); } diff --git a/src/main/java/derms/replica2/SwapResource.java b/src/main/java/derms/replica2/SwapResource.java index cc65f29..fbd2cf9 100644 --- a/src/main/java/derms/replica2/SwapResource.java +++ b/src/main/java/derms/replica2/SwapResource.java @@ -219,7 +219,7 @@ class SwapResource { private void returnOldResource(Resource r) { r.isBorrowed = false; - r.borrower = new CoordinatorID(); + r.borrower = request.cid; r.borrowDuration = -1; } } |