Search in sources :

Example 6 with Utils

use of net.dempsy.router.shardutils.Utils 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));
    }
}
Also used : RoutingInboundManager(net.dempsy.router.RoutingInboundManager) Utils(net.dempsy.router.shardutils.Utils) ClusterId(net.dempsy.config.ClusterId) RoutingStrategy(net.dempsy.router.RoutingStrategy) ContainerAddress(net.dempsy.router.RoutingStrategy.ContainerAddress) Test(org.junit.Test)

Example 7 with Utils

use of net.dempsy.router.shardutils.Utils 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);
    }
}
Also used : ClusterId(net.dempsy.config.ClusterId) ContainerAddress(net.dempsy.router.RoutingStrategy.ContainerAddress) RoutingInboundManager(net.dempsy.router.RoutingInboundManager) GroupDetails(net.dempsy.router.group.intern.GroupDetails) Utils(net.dempsy.router.shardutils.Utils) RoutingStrategy(net.dempsy.router.RoutingStrategy) TestInfrastructure(net.dempsy.util.TestInfrastructure) Infrastructure(net.dempsy.Infrastructure) NodeAddress(net.dempsy.transport.NodeAddress) Test(org.junit.Test)

Example 8 with Utils

use of net.dempsy.router.shardutils.Utils 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));
    }
}
Also used : ClusterId(net.dempsy.config.ClusterId) Utils(net.dempsy.router.shardutils.Utils) RoutingStrategy(net.dempsy.router.RoutingStrategy) RoutingStrategyManager(net.dempsy.router.RoutingStrategyManager) Manager(net.dempsy.Manager) ContainerAddress(net.dempsy.router.RoutingStrategy.ContainerAddress) Test(org.junit.Test)

Aggregations

ClusterId (net.dempsy.config.ClusterId)8 RoutingStrategy (net.dempsy.router.RoutingStrategy)8 ContainerAddress (net.dempsy.router.RoutingStrategy.ContainerAddress)8 Utils (net.dempsy.router.shardutils.Utils)8 Test (org.junit.Test)8 TestInfrastructure (net.dempsy.util.TestInfrastructure)6 Infrastructure (net.dempsy.Infrastructure)4 Manager (net.dempsy.Manager)4 ClusterInfoSession (net.dempsy.cluster.ClusterInfoSession)4 RoutingInboundManager (net.dempsy.router.RoutingInboundManager)4 RoutingStrategyManager (net.dempsy.router.RoutingStrategyManager)4 NodeAddress (net.dempsy.transport.NodeAddress)4 GroupDetails (net.dempsy.router.group.intern.GroupDetails)3 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2