assertEquals(2, server.finishedIterationCount());
}
@Test
public void testCrossNodeData() throws Exception {
LabelPropagation lp1 =
new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE1),
wdog, PartialToyBuilder.NODE1, props);
LabelPropagation lp2 =
new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE2),
wdog, PartialToyBuilder.NODE2, props);
LabelPropagation lp3 =
new LabelPropagation(new PartialToyBuilder(PartialToyBuilder.NODE3),
wdog, PartialToyBuilder.NODE3, props);
long run = 1;
lp1.prepareAlgorithm(run);
lp2.prepareAlgorithm(run);
lp3.prepareAlgorithm(run);
// Wait until all 3 callbacks have occurred
int count = 0;
while (server.readyToBeginCount() < 3) {
Thread.sleep(5);
if (++count > MAX_SLEEP_COUNT) {
fail("Too much time sleeping");
}
}
// examine the node conflict map -it is public so I can get it here
assertEquals(2, lp1.getNodeConflictMap().size());
Set<Long> expected = new HashSet<Long>();
expected.add(PartialToyBuilder.NODE2);
expected.add(PartialToyBuilder.NODE3);
assertTrue(expected.containsAll(lp1.getNodeConflictMap().keySet()));
Map<Object, Long> map =
lp1.getNodeConflictMap().get(PartialToyBuilder.NODE2);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj1"));
map = lp1.getNodeConflictMap().get(PartialToyBuilder.NODE3);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj2"));
assertEquals(1, lp2.getNodeConflictMap().size());
map = lp2.getNodeConflictMap().get(PartialToyBuilder.NODE1);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj1"));
assertEquals(1, lp3.getNodeConflictMap().size());
map = lp3.getNodeConflictMap().get(PartialToyBuilder.NODE1);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj2"));
//public Map<Long, Map<Object, Integer>> nodeConflictMap
System.out.println("NODE1 nodeConflictMap");
printNodeConflictMap(lp1);
System.out.println("NODE2 nodeConflictMap");
printNodeConflictMap(lp2);
System.out.println("NODE3 nodeConflictMap");
printNodeConflictMap(lp3);
// Clear out old information
lp1.getAffinityGroups(run, true);
lp2.getAffinityGroups(run, true);
lp3.getAffinityGroups(run, true);
server.clear();
System.out.println("Exchanging info a second time");
run++;
lp3.prepareAlgorithm(run);
lp2.prepareAlgorithm(run);
lp1.prepareAlgorithm(run);
// Wait until all 3 callbacks have occurred
count = 0;
while (server.readyToBeginCount() < 3) {
Thread.sleep(5);
if (++count > MAX_SLEEP_COUNT) {
fail("Too much time sleeping");
}
}
// examine the node conflict map -it is public so I can get it here
// Expect same result as above
assertEquals(2, lp1.getNodeConflictMap().size());
expected = new HashSet<Long>();
expected.add(PartialToyBuilder.NODE2);
expected.add(PartialToyBuilder.NODE3);
assertTrue(expected.containsAll(lp1.getNodeConflictMap().keySet()));
map = lp1.getNodeConflictMap().get(PartialToyBuilder.NODE2);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj1"));
map = lp1.getNodeConflictMap().get(PartialToyBuilder.NODE3);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj2"));
assertEquals(1, lp2.getNodeConflictMap().size());
map = lp2.getNodeConflictMap().get(PartialToyBuilder.NODE1);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj1"));
assertEquals(1, lp3.getNodeConflictMap().size());
map = lp3.getNodeConflictMap().get(PartialToyBuilder.NODE1);
assertEquals(1, map.size());
assertTrue(map.containsKey("obj2"));
//public Map<Long, Map<Object, Integer>> nodeConflictMap
System.out.println("NODE1 nodeConflictMap");