use of net.dempsy.config.ClusterId in project Dempsy by Dempsy.
the class TestContainer method setUp.
@Before
public void setUp() throws Exception {
justThrowMe = null;
throwMeInActivation = null;
track(new SystemPropertyManager()).set("container-type", containerId);
context = track(new ClassPathXmlApplicationContext(ctx));
sessionFactory = new LocalClusterSessionFactory();
final Node node = context.getBean(Node.class);
manager = track(new NodeManager()).node(node).collaborator(track(sessionFactory.createSession())).start();
statsCollector = manager.getClusterStatsCollector(new ClusterId("test-app", "test-cluster"));
container = manager.getContainers().get(0);
assertTrue(poll(manager, m -> m.isReady()));
}
use of net.dempsy.config.ClusterId in project Dempsy by Dempsy.
the class TestSimpleRoutingStrategy method testInboundHappyPathRegister.
@Test
public void testInboundHappyPathRegister() throws Exception {
final Manager<RoutingStrategy.Inbound> manager = new Manager<>(RoutingStrategy.Inbound.class);
try (final RoutingStrategy.Inbound ib = manager.getAssociatedInstance(SimpleRoutingStrategy.class.getPackage().getName())) {
assertNotNull(ib);
assertTrue(SimpleInboundSide.class.isAssignableFrom(ib.getClass()));
ib.setContainerDetails(new ClusterId("test", "test"), new ContainerAddress(new DummyNodeAddress(), 0), (l, m) -> {
});
ib.start(infra);
assertTrue(waitForReg(session));
}
}
use of net.dempsy.config.ClusterId in project Dempsy by Dempsy.
the class TestSimpleRoutingStrategy method testInboundWithOutbound.
@Test
public void testInboundWithOutbound() throws Exception {
final Manager<RoutingStrategy.Inbound> manager = new Manager<>(RoutingStrategy.Inbound.class);
try (final RoutingStrategy.Inbound ib = manager.getAssociatedInstance(SimpleRoutingStrategy.class.getPackage().getName())) {
assertNotNull(ib);
assertTrue(SimpleInboundSide.class.isAssignableFrom(ib.getClass()));
final ClusterId cid = new ClusterId("test", "test");
ib.setContainerDetails(cid, new ContainerAddress(new DummyNodeAddress("here"), 0), (l, m) -> {
});
ib.start(infra);
assertTrue(waitForReg(session));
try (final ClusterInfoSession ses2 = sessFact.createSession()) {
try (final RoutingStrategyManager obman = chain(new RoutingStrategyManager(), o -> o.start(makeInfra(ses2, sched)));
final RoutingStrategy.Factory obf = obman.getAssociatedInstance(SimpleRoutingStrategy.class.getPackage().getName())) {
obf.start(makeInfra(ses2, sched));
final RoutingStrategy.Router ob = obf.getStrategy(cid);
final KeyedMessageWithType km = new KeyedMessageWithType(null, null, "");
assertTrue(poll(o -> ob.selectDestinationForMessage(km) != null));
final ContainerAddress ca = ob.selectDestinationForMessage(km);
assertNotNull(ca);
assertEquals("here", ((DummyNodeAddress) ca.node).name);
// now distupt the session
session.close();
// the destination should clear until a new in runs
assertTrue(poll(o -> ob.selectDestinationForMessage(km) == null));
try (ClusterInfoSession ses3 = sessFact.createSession();
RoutingStrategy.Inbound ib2 = manager.getAssociatedInstance(SimpleRoutingStrategy.class.getPackage().getName())) {
ib2.setContainerDetails(cid, ca, (l, m) -> {
});
ib2.start(makeInfra(ses3, sched));
assertTrue(poll(o -> ob.selectDestinationForMessage(km) != null));
}
}
}
}
}
use of net.dempsy.config.ClusterId in project Dempsy by Dempsy.
the class TestGroupRoutingStrategy method testInboundSimpleHappyPathRegister.
@Test
public void testInboundSimpleHappyPathRegister() throws Exception {
final int numShardsToExpect = Integer.parseInt(Utils.DEFAULT_TOTAL_SHARDS);
final RoutingInboundManager manager = new RoutingInboundManager();
try (final RoutingStrategy.Inbound ib = manager.getAssociatedInstance(ClusterGroupInbound.class.getPackage().getName() + ":testInboundSimpleHappyPathRegister")) {
final Utils<Object> msutils = new Utils<>(infra, "testInboundSimpleHappyPathRegister", new Object());
assertNotNull(ib);
assertTrue(ClusterGroupInbound.Proxy.class.isAssignableFrom(ib.getClass()));
ib.setContainerDetails(new ClusterId("test", "test"), new ContainerAddress(new DummyNodeAddress("testInboundSimpleHappyPathRegister"), 0), (l, m) -> {
});
ib.start(infra);
assertTrue(waitForShards(session, msutils, numShardsToExpect));
}
}
use of net.dempsy.config.ClusterId in project Dempsy by Dempsy.
the class TestGroupRoutingStrategy method testInboundResillience.
@Test
public void testInboundResillience() throws Exception {
final int numShardsToExpect = Integer.parseInt(Utils.DEFAULT_TOTAL_SHARDS);
final String groupName = "testInboundResillience";
final Manager<RoutingStrategy.Inbound> manager = new RoutingInboundManager();
try (final RoutingStrategy.Inbound ib = manager.getAssociatedInstance(ClusterGroupInbound.class.getPackage().getName() + ":" + groupName)) {
final ClusterId clusterId = super.setTestName("testInboundResillience");
final NodeAddress na = new DummyNodeAddress("theOnlyNode");
final ContainerAddress ca = new ContainerAddress(na, 0);
final GroupDetails gd = new GroupDetails(groupName, na);
final Infrastructure infra = makeInfra(session, sched);
final Utils<GroupDetails> msutils = new Utils<>(infra, groupName, gd);
ib.setContainerDetails(clusterId, ca, (l, m) -> {
});
ib.start(infra);
checkForShardDistribution(session, msutils, numShardsToExpect, 1);
disruptor.accept(session);
checkForShardDistribution(session, msutils, numShardsToExpect, 1);
}
}
Aggregations