Search in sources :

Example 1 with BasicNodeStatsCollector

use of net.dempsy.monitoring.basic.BasicNodeStatsCollector in project Dempsy by Dempsy.

the class TestContainer method addOutputCatchStage.

public NodeManager addOutputCatchStage() throws InterruptedException {
    // =======================================================
    // configure an output catcher tier
    final Node out = new Node.Builder("test-app").defaultRoutingStrategyId("net.dempsy.router.simple").receiver(new BlockingQueueReceiver(new ArrayBlockingQueue<>(16))).nodeStatsCollector(new BasicNodeStatsCollector()).cluster("output-catch").mp(new MessageProcessor<OutputCatcher>(new OutputCatcher())).build();
    out.validate();
    final NodeManager nman = track(new NodeManager()).node(out).collaborator(track(sessionFactory.createSession())).start();
    // wait until we can actually reach the output-catch cluster from the main node
    assertTrue(poll(o -> {
        try {
            return canReach(getRouter(manager), "output-catch", new KeyExtractor().extract(new OutputMessage("foo", 1, 1)).iterator().next());
        } catch (final Exception e) {
            return false;
        }
    }));
    // =======================================================
    return nman;
}
Also used : Arrays(java.util.Arrays) Node(net.dempsy.config.Node) NodeManager(net.dempsy.NodeManager) ContainerTestMessage(net.dempsy.container.mocks.ContainerTestMessage) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) After(org.junit.After) Parameterized(org.junit.runners.Parameterized) MessageKey(net.dempsy.lifecycle.annotation.MessageKey) MessageHandler(net.dempsy.lifecycle.annotation.MessageHandler) Collection(java.util.Collection) Operation(net.dempsy.container.Container.Operation) Functional.uncheck(net.dempsy.util.Functional.uncheck) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Activation(net.dempsy.lifecycle.annotation.Activation) KeyExtractor(net.dempsy.lifecycle.annotation.utils.KeyExtractor) LockingContainer(net.dempsy.container.locking.LockingContainer) OutputMessage(net.dempsy.container.mocks.OutputMessage) Output(net.dempsy.lifecycle.annotation.Output) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Adaptor(net.dempsy.messages.Adaptor) AccessUtil.canReach(net.dempsy.AccessUtil.canReach) Start(net.dempsy.lifecycle.annotation.Start) Assert.assertFalse(org.junit.Assert.assertFalse) Evictable(net.dempsy.lifecycle.annotation.Evictable) MessageProcessor(net.dempsy.lifecycle.annotation.MessageProcessor) AccessUtil.getRouter(net.dempsy.AccessUtil.getRouter) Mp(net.dempsy.lifecycle.annotation.Mp) BlockingQueueReceiver(net.dempsy.transport.blockingqueue.BlockingQueueReceiver) NonLockingAltContainer(net.dempsy.container.altnonlocking.NonLockingAltContainer) MessageType(net.dempsy.lifecycle.annotation.MessageType) Dispatcher(net.dempsy.messages.Dispatcher) KeyedMessageWithType(net.dempsy.messages.KeyedMessageWithType) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) DempsyException(net.dempsy.DempsyException) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ClusterId(net.dempsy.config.ClusterId) Before(org.junit.Before) LocalClusterSessionFactory(net.dempsy.cluster.local.LocalClusterSessionFactory) Functional.recheck(net.dempsy.util.Functional.recheck) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) KeyedMessage(net.dempsy.messages.KeyedMessage) SystemPropertyManager(net.dempsy.util.SystemPropertyManager) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Passivation(net.dempsy.lifecycle.annotation.Passivation) AtomicLong(java.util.concurrent.atomic.AtomicLong) ClusterStatsCollector(net.dempsy.monitoring.ClusterStatsCollector) ConditionPoll.poll(net.dempsy.utils.test.ConditionPoll.poll) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) NodeManager(net.dempsy.NodeManager) OutputMessage(net.dempsy.container.mocks.OutputMessage) BlockingQueueReceiver(net.dempsy.transport.blockingqueue.BlockingQueueReceiver) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Node(net.dempsy.config.Node) MessageProcessor(net.dempsy.lifecycle.annotation.MessageProcessor) KeyExtractor(net.dempsy.lifecycle.annotation.utils.KeyExtractor) DempsyException(net.dempsy.DempsyException) BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector)

Example 2 with BasicNodeStatsCollector

use of net.dempsy.monitoring.basic.BasicNodeStatsCollector in project Dempsy by Dempsy.

the class TestInstanceManager method setupContainer.

@SuppressWarnings("resource")
public Container setupContainer(final MessageProcessorLifecycle<?> prototype) throws ContainerException {
    dispatcher = new DummyDispatcher();
    statsCollector = new BasicClusterStatsCollector();
    manager = new NonLockingAltContainer().setMessageProcessor(prototype).setClusterId(new ClusterId("test", "test"));
    manager.setDispatcher(dispatcher);
    manager.setInbound(new DummyInbound());
    tm = new DefaultThreadingModel(TestInstanceManager.class.getName());
    tm.start(TestInstanceManager.class.getName());
    manager.start(new TestInfrastructure(tm) {

        BasicNodeStatsCollector nStats = new BasicNodeStatsCollector();

        @Override
        public ClusterStatsCollector getClusterStatsCollector(final ClusterId clusterId) {
            return statsCollector;
        }

        @Override
        public NodeStatsCollector getNodeStatsCollector() {
            return nStats;
        }
    });
    return manager;
}
Also used : DummyInbound(net.dempsy.container.mocks.DummyInbound) BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector) NodeStatsCollector(net.dempsy.monitoring.NodeStatsCollector) TestInfrastructure(net.dempsy.util.TestInfrastructure) BasicClusterStatsCollector(net.dempsy.monitoring.basic.BasicClusterStatsCollector) ClusterStatsCollector(net.dempsy.monitoring.ClusterStatsCollector) ClusterId(net.dempsy.config.ClusterId) BasicClusterStatsCollector(net.dempsy.monitoring.basic.BasicClusterStatsCollector) DefaultThreadingModel(net.dempsy.threading.DefaultThreadingModel) NonLockingAltContainer(net.dempsy.container.altnonlocking.NonLockingAltContainer) BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector)

Example 3 with BasicNodeStatsCollector

use of net.dempsy.monitoring.basic.BasicNodeStatsCollector in project Dempsy by Dempsy.

the class TestContainerLoadHandling method setUp.

@Before
public void setUp() throws Exception {
    final ClusterId cid = new ClusterId("TestContainerLoadHandling", "test" + sequence++);
    dispatcher = new MockDispatcher();
    final BasicClusterStatsCollector sc = new BasicClusterStatsCollector();
    clusterStats = sc;
    nodeStats = new BasicNodeStatsCollector();
    container = tr.track(new Manager<Container>(Container.class).getAssociatedInstance(containerId)).setMessageProcessor(new MessageProcessor<TestMessageProcessor>(new TestMessageProcessor())).setClusterId(cid);
    container.setDispatcher(dispatcher);
    container.setInbound(new DummyInbound());
    container.start(new TestInfrastructure(null, null) {

        @Override
        public ClusterStatsCollector getClusterStatsCollector(final ClusterId clusterId) {
            return sc;
        }

        @Override
        public NodeStatsCollector getNodeStatsCollector() {
            return nodeStats;
        }
    });
    forceOutputException = false;
    stillRunning = true;
}
Also used : BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector) NodeStatsCollector(net.dempsy.monitoring.NodeStatsCollector) TestInfrastructure(net.dempsy.util.TestInfrastructure) ClusterId(net.dempsy.config.ClusterId) BasicClusterStatsCollector(net.dempsy.monitoring.basic.BasicClusterStatsCollector) DummyInbound(net.dempsy.container.mocks.DummyInbound) NonLockingAltContainer(net.dempsy.container.altnonlocking.NonLockingAltContainer) LockingContainer(net.dempsy.container.locking.LockingContainer) BasicClusterStatsCollector(net.dempsy.monitoring.basic.BasicClusterStatsCollector) ClusterStatsCollector(net.dempsy.monitoring.ClusterStatsCollector) BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector) Before(org.junit.Before)

Example 4 with BasicNodeStatsCollector

use of net.dempsy.monitoring.basic.BasicNodeStatsCollector in project Dempsy by Dempsy.

the class TestInstanceManager method setupContainer.

@SuppressWarnings("resource")
public LockingContainer setupContainer(final MessageProcessorLifecycle<?> prototype) throws ContainerException {
    dispatcher = new DummyDispatcher();
    statsCollector = new BasicClusterStatsCollector();
    nodeStats = new BasicNodeStatsCollector();
    container = (LockingContainer) new LockingContainer().setMessageProcessor(prototype).setClusterId(new ClusterId("test", "test"));
    container.setDispatcher(dispatcher);
    container.setInbound(new DummyInbound());
    tm = new DefaultThreadingModel(TestInstanceManager.class.getName());
    tm.start(TestInstanceManager.class.getName());
    container.start(new TestInfrastructure(tm) {

        @Override
        public BasicClusterStatsCollector getClusterStatsCollector(final ClusterId clusterId) {
            return statsCollector;
        }

        @Override
        public NodeStatsCollector getNodeStatsCollector() {
            return nodeStats;
        }
    });
    return container;
}
Also used : DummyInbound(net.dempsy.container.mocks.DummyInbound) BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector) NodeStatsCollector(net.dempsy.monitoring.NodeStatsCollector) TestInfrastructure(net.dempsy.util.TestInfrastructure) ClusterId(net.dempsy.config.ClusterId) BasicClusterStatsCollector(net.dempsy.monitoring.basic.BasicClusterStatsCollector) DefaultThreadingModel(net.dempsy.threading.DefaultThreadingModel) BasicNodeStatsCollector(net.dempsy.monitoring.basic.BasicNodeStatsCollector)

Aggregations

ClusterId (net.dempsy.config.ClusterId)4 BasicNodeStatsCollector (net.dempsy.monitoring.basic.BasicNodeStatsCollector)4 NonLockingAltContainer (net.dempsy.container.altnonlocking.NonLockingAltContainer)3 DummyInbound (net.dempsy.container.mocks.DummyInbound)3 ClusterStatsCollector (net.dempsy.monitoring.ClusterStatsCollector)3 NodeStatsCollector (net.dempsy.monitoring.NodeStatsCollector)3 BasicClusterStatsCollector (net.dempsy.monitoring.basic.BasicClusterStatsCollector)3 TestInfrastructure (net.dempsy.util.TestInfrastructure)3 LockingContainer (net.dempsy.container.locking.LockingContainer)2 Before (org.junit.Before)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1