Skip to content

Commit

Permalink
Include the node's identify in the json logging to be compatible with…
Browse files Browse the repository at this point in the history
… ShiViz (https://bestchai.bitbucket.io/shiviz).

Regex:

^{"event":"(<|>|d)","node":(?<host>[0-9]?),"pkt":{("snd":(?<src>[0-9]?),"rcv":(?<rcv>[0-9]?),"msg":(?<event>({"type":"tok","q":-?[0-9]*,"color":"(white|black)"}|{"type":"(pl|trm|w|d)"})),|)"vc":(?<clock>.*)}}
  • Loading branch information
lemmy committed Apr 10, 2023
1 parent 61d6be7 commit 7897628
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions specifications/ewd998/impl/src/EWD998.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class EWD998 {
private static final JsonPrimitive PL = new JsonPrimitive("pl");

private static final String EVENT = "event";
private static final String NODE = "node";
private static final JsonPrimitive IN = new JsonPrimitive("<");
private static final JsonPrimitive OUT = new JsonPrimitive(">");

Expand Down Expand Up @@ -132,6 +133,7 @@ public EWD998(final Map<Integer, Pair> nodes, final int myId, final boolean isIn
// event shows is this is an incoming ("<") or outgoing (">") packet.
final JsonObject logline = new JsonObject();
logline.add(EVENT, IN);
logline.add(NODE, new JsonPrimitive(myId));
pkt.add(VC, vc.tickAndMerge(pkt.get(VC).getAsJsonObject()));
logline.add(PKT, pkt);
System.out.println(logline);
Expand Down Expand Up @@ -316,6 +318,7 @@ private void sendMsg(final int sender, final int receiver, final JsonObject msg)
pkt.add(VC, vc.tick());
final JsonObject logline = new JsonObject();
logline.add(EVENT, OUT);
logline.add(NODE, new JsonPrimitive(sender));
logline.add(PKT, pkt);

final Pair p = nodes.get(receiver);
Expand Down

0 comments on commit 7897628

Please sign in to comment.