clients.get(0).gossipSharedData(sharedNodeData("category", "distributed"));
clients.get(0).gossipSharedData(sharedNodeData("category", "distributed")); clients.get(0).gossipSharedData(sharedNodeData("organization", "apache")); clients.get(0).gossipSharedData(sharedNodeData("organization", "apache-gossip"));
nodes.get(0).gossipSharedData(sharedNodeData("Dc1Rack1", "I am belong to Dc1", new DataCenterReplicable<>())); nodes.get(2).gossipSharedData(sharedNodeData("Dc2Rack1", "I am belong to Dc2", new DataCenterReplicable<>()));
nodes.get(0).gossipSharedData(sharedNodeData("public", "I am visible to all", new AllReplicable<>())); nodes.get(0).gossipSharedData(sharedNodeData("private", "I am private", new NotReplicable<>())); whiteList.add(nodes.get(1).getMyself()); nodes.get(0).gossipSharedData(sharedNodeData("wl", "white list", new WhiteListReplicable<>(whiteList))); blackList.add(nodes.get(1).getMyself()); nodes.get(0).gossipSharedData(sharedNodeData("bl", "black list", new BlackListReplicable<>(blackList)));
@Test public void simpleDataTest(){ TUnit.assertThat(() -> { int total = 0; for (GossipManager client : clients){ total += client.getLiveMembers().size(); } return total; }).afterWaitingAtMost(10, TimeUnit.SECONDS).isEqualTo(2); clients.get(0).gossipPerNodeData(generatePerNodeMsg("a", "b")); clients.get(0).gossipSharedData(generateSharedMsg("a", "c")); TUnit.assertThat(() -> { PerNodeDataMessage x = clients.get(1).findPerNodeGossipData(1 + "", "a"); if (x == null) return ""; else return x.getPayload(); }).afterWaitingAtMost(10, TimeUnit.SECONDS).isEqualTo("b"); TUnit.assertThat(() -> { SharedDataMessage x = clients.get(1).findSharedGossipData("a"); if (x == null) return ""; else return x.getPayload(); }).afterWaitingAtMost(10, TimeUnit.SECONDS).isEqualTo("c"); }
gossipService.init(); gossipService.gossipPerNodeData(getToothpick()); gossipService.gossipSharedData(getAnotherToothpick()); gossipService.getUserDataState().writePerNodeToDisk(); gossipService.getUserDataState().writeSharedToDisk();
@Test public void testReaperOneShot() { GossipSettings settings = new GossipSettings(); settings.setPersistRingState(false); settings.setPersistDataState(false); settings.setTransportManagerClass("org.apache.gossip.transport.UnitTestTransportManager"); settings.setProtocolManagerClass("org.apache.gossip.protocol.UnitTestProtocolManager"); GossipManager gm = GossipManagerBuilder.newBuilder().cluster("abc").gossipSettings(settings) .id(myId).uri(URI.create("udp://localhost:6000")).registry(registry).build(); gm.init(); gm.gossipPerNodeData(perNodeDatum(key, value)); gm.gossipSharedData(sharedDatum(key, value)); assertDataIsAtCorrectValue(gm); gm.getDataReaper().runPerNodeOnce(); gm.getDataReaper().runSharedOnce(); assertDataIsRemoved(gm); gm.shutdown(); }