use of net.dempsy.cluster.ClusterInfoSessionFactory in project Dempsy by Dempsy.
the class DempsyBaseTest method runCombos.
protected void runCombos(final String testName, final ComboFilter filter, final String[][] ctxs, final String[][][] perNodeProps, final TestToRun test) throws Exception {
if (filter != null && !filter.filter(routerId, containerId, sessionType, transportType, serializerType))
return;
final long comboSequence = runComboSequence.getAndIncrement();
currentAppName = testName + "-" + comboSequence;
LOGGER.info("=====================================================================================");
LOGGER.info("======== Running (" + comboSequence + ") " + testName + " with " + routerId + ", " + containerId + ", " + sessionType + ", " + threadingModelDescription + ", " + transportType + "/" + serializerType);
try (final ServiceTracker tr = new ServiceTracker()) {
currentlyTracking = tr;
tr.track(new SystemPropertyManager()).set("routing-strategy", ROUTER_ID_PREFIX + routerId).set("container-type", CONTAINER_ID_PREFIX + containerId).set("test-name", currentAppName).setIfAbsent("total_shards", Integer.toString(NUM_MICROSHARDS));
// instantiate session factory
final ClusterInfoSessionFactory sessFact = tr.track(new ClassPathXmlApplicationContext(COLLAB_CTX_PREFIX + sessionType + COLLAB_CTX_SUFFIX)).getBean(ClusterInfoSessionFactory.class);
currentSessionFactory = sessFact;
final List<NodeManagerWithContext> reverseCpCtxs = reverseRange(0, ctxs.length).mapToObj(i -> {
try (final SystemPropertyManager p2 = new SystemPropertyManager()) {
if (perNodeProps != null && perNodeProps[i] != null) {
for (final String[] kv : perNodeProps[i]) {
if (kv != null) {
if (kv.length != 2)
throw new IllegalArgumentException("Invalid KV Pair passed for per-node property");
p2.set(kv[0], kv[1]);
}
}
}
final NodeManagerWithContext ret = makeNode(ctxs[i]);
// we can only do this level of polling when the min_nodes isn't set or is set to 1.
final String minNodesProp = System.getProperty("min_nodes");
if (minNodesProp != null && Integer.parseInt(minNodesProp) == 1)
assertTrue(qpoll(ret, o -> o.manager.isReady()));
return ret;
}
}).collect(Collectors.toList());
final List<NodeManagerWithContext> cpCtxs = reverseRange(0, reverseCpCtxs.size()).mapToObj(i -> reverseCpCtxs.get(i)).collect(Collectors.toList());
for (final NodeManagerWithContext n : cpCtxs) assertTrue(poll(o -> n.manager.isReady()));
test.test(new Nodes(cpCtxs, sessFact));
currentlyTracking = null;
} finally {
LocalClusterSessionFactory.completeReset();
BlockingQueueAddress.completeReset();
ClassTracker.dumpResults();
}
test.postShutdown();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
System.gc();
for (final long endTime = System.currentTimeMillis() + TEN_SECONDS; Thread.activeCount() > 3; ) {
ignore(() -> Thread.sleep(10));
if (Thread.activeCount() > 3 && (System.currentTimeMillis() > endTime)) {
LOGGER.error("There appears to be an incomplete shutdown! There are {} threads running after stop.", Thread.activeCount());
break;
}
}
}
Aggregations