GOSSIP-55 Added event handlers to notify share data and per node data changes

This commit is contained in:
Mirage Abeysekara
2017-06-01 22:21:14 +05:30
committed by Miraj Abeysekara
parent 9c9d96e564
commit ade33a9e58
10 changed files with 786 additions and 6 deletions

View File

@ -79,10 +79,21 @@ public class StandAloneNodeCrdtOrSet {
} else if (op == 'g') {
gcount(val, gossipService);
}
if (op == 'l') {
listen(val, gossipService);
}
}
}
}
private static void listen(String val, GossipManager gossipManager) {
gossipManager.registerSharedDataSubscriber((key, oldValue, newValue) -> {
if (key.equals(val)) {
System.out.println("Event Handler fired! " + oldValue + " " + newValue);
}
});
}
private static void gcount(String val, GossipManager gossipManager) {
GrowOnlyCounter c = (GrowOnlyCounter) gossipManager.findCrdt("def");
Long l = Long.valueOf(val);