Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Malay committed Oct 23, 2024
1 parent fee5c56 commit cbb00aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 251 deletions.
246 changes: 0 additions & 246 deletions ChandyLamport.java

This file was deleted.

4 changes: 3 additions & 1 deletion Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ enum MessageType {
public class Message implements Serializable {
public int id = -1;
public MessageType messageType;
public Vector<Integer> clock;
public int clock;
String key;

public Message(MessageType type, int id, Vector<Integer> timestamp) {
this.messageType = type;
this.id = id;
this.clock = timestamp;
this.key = key;
}

public byte[] toMessageBytes() throws IOException {
Expand Down
19 changes: 15 additions & 4 deletions Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class Node {
int id;
String name;
String port;
List<List<Integer>> neighbours = new ArrayList<>();
// Config
int totalNodes;
int requestDelay;
Expand Down Expand Up @@ -44,11 +43,11 @@ public static void main(String[] args) {
node = new Node(-1);
// Parse the config file
node.readConfig();
// Init Vector Clock;
node.initVectorClock();
// Init Keys
node.initKeys();
// Print details
node.printNodeConfig();
node.printNodeNeighbours();
node.printNodeKeys();

// Server
node.server = new Server(node.getPort(), node);
Expand Down Expand Up @@ -137,6 +136,11 @@ public void readConfig() {
}
}

public void initKeys() {
for (int i = id + 1; i <= totalNodes; i++) {
this.keys.add(i);
}
}
public String getHost() {
return idToHost_PortMap.get(id).get(0);
}
Expand Down Expand Up @@ -181,6 +185,13 @@ public void printNodeConfig() {
System.out.println("Max # of Request: " + maxRequest);
System.out.println("=====================================\n");
}
public void printNodeKeys() {
System.out.println("============= Node Keys =============");
for (Integer x : keys) {
System.out.print(x + ", ");
}
System.out.println("=====================================\n");
}

public void printNodeVectorClock() {
int totalSent = 0, totalReceive = 0;
Expand Down

0 comments on commit cbb00aa

Please sign in to comment.