use of net.dempsy.Manager 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.Manager in project Dempsy by Dempsy.
the class TestManagedRoutingStrategy method testInboundSimpleHappyPathRegister.
@Test
public void testInboundSimpleHappyPathRegister() throws Exception {
final int numShardsToExpect = Integer.parseInt(Utils.DEFAULT_TOTAL_SHARDS);
final Manager<RoutingStrategy.Inbound> manager = new Manager<>(RoutingStrategy.Inbound.class);
try (final RoutingStrategy.Inbound ib = manager.getAssociatedInstance(ManagedInbound.class.getPackage().getName())) {
final ClusterId clusterId = new ClusterId("test", "test");
final Utils<ContainerAddress> msutils = new Utils<>(infra, clusterId.clusterName, new ContainerAddress(new DummyNodeAddress("testInboundSimpleHappyPathRegister"), 0));
assertNotNull(ib);
assertTrue(ManagedInbound.class.isAssignableFrom(ib.getClass()));
ib.setContainerDetails(clusterId, new ContainerAddress(new DummyNodeAddress("testInboundSimpleHappyPathRegister"), 0), (l, m) -> {
});
ib.start(infra);
assertTrue(waitForShards(session, msutils, numShardsToExpect));
}
}
Aggregations