// setup
Properties props = new Properties();
int serverPort = SgsTestNode.getNextUniquePort();
props.put("com.sun.sgs.impl.service.nodemap.affinity.server.port",
String.valueOf(serverPort));
LabelPropagationServer server =
new LabelPropagationServer(collector, wdog, props);
props.put("com.sun.sgs.impl.service.nodemap.affinity.numThreads",
String.valueOf(numThreads));
props.put(LPADriver.GRAPH_CLASS_PROPERTY, builderName);
LabelPropagation lp1 =
new LabelPropagation(
new DistributedZachBuilder(DistributedZachBuilder.NODE1),
wdog, DistributedZachBuilder.NODE1, props);
LabelPropagation lp2 =
new LabelPropagation(
new DistributedZachBuilder(DistributedZachBuilder.NODE2),
wdog, DistributedZachBuilder.NODE2, props);
LabelPropagation lp3 =
new LabelPropagation(
new DistributedZachBuilder(DistributedZachBuilder.NODE3),
wdog, DistributedZachBuilder.NODE3, props);
AffinityGroupFinderMXBean bean = (AffinityGroupFinderMXBean)
collector.getRegisteredMBean(AffinityGroupFinderMXBean.MXBEAN_NAME);
assertNotNull(bean);
bean.clear();
// Be sure the consumer is turned on
collector.getConsumer(AffinityGroupFinderStats.CONS_NAME).
setProfileLevel(ProfileLevel.MAX);
double avgMod = 0.0;
double maxMod = 0.0;
double minMod = 1.0;
for (int i = 0; i < RUNS; i++) {
Set<AffinityGroup> groups =
Objects.uncheckedCast(server.findAffinityGroups());
double mod =
AffinityGroupGoodness.calcModularity(
new ZachBuilder().getAffinityGraph(), groups);
avgMod = avgMod + mod;
maxMod = Math.max(maxMod, mod);
minMod = Math.min(minMod, mod);
}
String name;
if (WeightedGraphBuilder.class.getName().equals(builderName)) {
name = "DIST weighted";
} else {
name = "DIST bipartite";
}
System.out.printf(name + " (%d runs, %d threads): " +
"avg time : %4.2f ms, " +
" time range [%d - %d ms] " +
" avg iters : %4.2f, avg modularity: %.4f, " +
" modularity range [%.4f - %.4f] %n",
RUNS, numThreads,
bean.getAvgRunTime(),
bean.getMinRunTime(),
bean.getMaxRunTime(),
bean.getAvgIterations(),
avgMod/(double) RUNS,
minMod, maxMod);
server.shutdown();
}