Search in sources :

Example 1 with StatsCollectorFactoryCoda

use of com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda in project Dempsy by Dempsy.

the class TestMpContainerLoadHandling method setUp.

@Before
public void setUp() throws Exception {
    ClusterId cid = new ClusterId("TestMpContainerLoadHandling", "test" + sequence++);
    dispatcher = new MockDispatcher();
    StatsCollectorCoda sc = new StatsCollectorCoda(cid, new StatsCollectorFactoryCoda().getNamingStrategy());
    stats = sc;
    JavaSerializer<Object> serializer = new JavaSerializer<Object>();
    container = new MpContainer(cid);
    container.setDispatcher(dispatcher);
    container.setStatCollector(sc);
    container.setSerializer(serializer);
    container.setPrototype(new TestMessageProcessor());
    forceOutputException = false;
}
Also used : StatsCollectorCoda(com.nokia.dempsy.monitoring.coda.StatsCollectorCoda) MpContainer(com.nokia.dempsy.container.MpContainer) ClusterId(com.nokia.dempsy.config.ClusterId) JavaSerializer(com.nokia.dempsy.serialization.java.JavaSerializer) StatsCollectorFactoryCoda(com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda) Before(org.junit.Before)

Example 2 with StatsCollectorFactoryCoda

use of com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda in project Dempsy by Dempsy.

the class TestZookeeperClusterResilience method getDempsyFor.

private static Dempsy getDempsyFor(ClusterId clusterId, ApplicationDefinition ad) throws Throwable {
    //------------------------------------------------------------------------------
    // here is a complete non-spring, non-DI Dempsy instantiation
    //------------------------------------------------------------------------------
    List<ApplicationDefinition> ads = new ArrayList<ApplicationDefinition>();
    ads.add(ad);
    Dempsy dempsy = new Dempsy();
    dempsy.setApplicationDefinitions(ads);
    dempsy.setClusterCheck(new SpecificClusterCheck(clusterId));
    dempsy.setDefaultRoutingStrategy(new DecentralizedRoutingStrategy(20, 1));
    dempsy.setDefaultSerializer(new JavaSerializer<Object>());
    dempsy.setDefaultStatsCollectorFactory(new StatsCollectorFactoryCoda());
    dempsy.setDefaultTransport(new TcpTransport());
    return dempsy;
}
Also used : DecentralizedRoutingStrategy(com.nokia.dempsy.router.DecentralizedRoutingStrategy) ApplicationDefinition(com.nokia.dempsy.config.ApplicationDefinition) SpecificClusterCheck(com.nokia.dempsy.router.SpecificClusterCheck) Dempsy(com.nokia.dempsy.Dempsy) ArrayList(java.util.ArrayList) TcpTransport(com.nokia.dempsy.messagetransport.tcp.TcpTransport) StatsCollectorFactoryCoda(com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda)

Example 3 with StatsCollectorFactoryCoda

use of com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda in project Dempsy by Dempsy.

the class TestInstanceManager method setupContainer.

//----------------------------------------------------------------------------
//  Test Cases
//----------------------------------------------------------------------------
public MpContainer setupContainer(Object prototype) throws ContainerException {
    DummyDispatcher dispatcher = new DummyDispatcher();
    StatsCollector stats = new StatsCollectorCoda(new ClusterId("test", "test"), new StatsCollectorFactoryCoda().getNamingStrategy());
    JavaSerializer<Object> serializer = new JavaSerializer<Object>();
    manager = new MpContainer(new ClusterId("test", "test"));
    manager.setDispatcher(dispatcher);
    manager.setStatCollector(stats);
    manager.setSerializer(serializer);
    manager.setPrototype(prototype);
    return manager;
}
Also used : StatsCollectorCoda(com.nokia.dempsy.monitoring.coda.StatsCollectorCoda) StatsCollector(com.nokia.dempsy.monitoring.StatsCollector) ClusterId(com.nokia.dempsy.config.ClusterId) JavaSerializer(com.nokia.dempsy.serialization.java.JavaSerializer) StatsCollectorFactoryCoda(com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda)

Example 4 with StatsCollectorFactoryCoda

use of com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda in project Dempsy by Dempsy.

the class TcpTransportTest method testTransportInstantiation.

/**
    * Just send a simple message and make sure it gets through.
    */
@Test
public void testTransportInstantiation() throws Throwable {
    final AtomicBoolean batchedAtLeastOnce = new AtomicBoolean(false);
    runAllCombinations(new Checker() {

        @Override
        public void check(int port, boolean localhost, long batchOutgoingMessagesDelayMillis) throws Throwable {
            final StatsCollector statsCollector = new StatsCollectorFactoryCoda().createStatsCollector(new ClusterId("test", "test-cluster"), new Destination() {
            });
            SenderFactory factory = null;
            TcpReceiver adaptor = null;
            try {
                boolean shouldBatch = batchOutgoingMessagesDelayMillis >= 0;
                if (shouldBatch)
                    batchedAtLeastOnce.set(true);
                TcpTransport transport = new TcpTransport();
                transport.setFailFast(getFailFast());
                // by default batching isn't disabled.
                assertFalse(transport.isBatchingDisabled());
                if (!shouldBatch)
                    transport.setDisableBatching(true);
                if (!shouldBatch)
                    assertTrue(transport.isBatchingDisabled());
                assertEquals(!shouldBatch, transport.isBatchingDisabled());
                //===========================================
                // setup the sender and receiver
                adaptor = (TcpReceiver) transport.createInbound(null);
                adaptor.setStatsCollector(statsCollector);
                StringListener receiver = new StringListener();
                adaptor.setListener(receiver);
                factory = transport.createOutbound(null, statsCollector);
                if (port > 0)
                    adaptor.setPort(port);
                if (localhost)
                    adaptor.setUseLocalhost(localhost);
                //===========================================
                // start the adaptor
                adaptor.start();
                // get the destination
                Destination destination = adaptor.getDestination();
                // send a message
                byte[] messageBytes = "Hello".getBytes();
                Sender sender = factory.getSender(destination);
                assertEquals((shouldBatch ? TcpTransport.defaultBatchingDelayMillis : -1), ((TcpSender) sender).getBatchOutgoingMessagesDelayMillis());
                sender.send(messageBytes);
                sender.send(messageBytes);
                // wait for it to be received.
                for (long endTime = System.currentTimeMillis() + baseTimeoutMillis; endTime > System.currentTimeMillis() && receiver.numMessages.get() < 2; ) Thread.sleep(1);
                assertEquals(2, receiver.numMessages.get());
                // verify everything came over ok.
                assertEquals(1, receiver.receivedStringMessages.size());
                assertEquals("Hello", receiver.receivedStringMessages.iterator().next());
                if (shouldBatch) {
                    // verify the histogram
                    Histogram histogram = ((TcpSender) sender).getBatchingHistogram();
                    assertEquals(calcMean(2), histogram.mean(), 0.0000001);
                    assertEquals(1, histogram.count());
                }
            } finally {
                if (factory != null)
                    factory.stop();
                if (adaptor != null)
                    adaptor.stop();
            }
        }

        @Override
        public String toString() {
            return "testTransportInstantiation";
        }
    });
    assertTrue(batchedAtLeastOnce.get());
}
Also used : Destination(com.nokia.dempsy.messagetransport.Destination) Histogram(com.yammer.metrics.core.Histogram) ClusterId(com.nokia.dempsy.config.ClusterId) StatsCollector(com.nokia.dempsy.monitoring.StatsCollector) BasicStatsCollector(com.nokia.dempsy.monitoring.basic.BasicStatsCollector) Sender(com.nokia.dempsy.messagetransport.Sender) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SenderFactory(com.nokia.dempsy.messagetransport.SenderFactory) StatsCollectorFactoryCoda(com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda) Test(org.junit.Test)

Aggregations

StatsCollectorFactoryCoda (com.nokia.dempsy.monitoring.coda.StatsCollectorFactoryCoda)4 ClusterId (com.nokia.dempsy.config.ClusterId)3 StatsCollector (com.nokia.dempsy.monitoring.StatsCollector)2 StatsCollectorCoda (com.nokia.dempsy.monitoring.coda.StatsCollectorCoda)2 JavaSerializer (com.nokia.dempsy.serialization.java.JavaSerializer)2 Dempsy (com.nokia.dempsy.Dempsy)1 ApplicationDefinition (com.nokia.dempsy.config.ApplicationDefinition)1 MpContainer (com.nokia.dempsy.container.MpContainer)1 Destination (com.nokia.dempsy.messagetransport.Destination)1 Sender (com.nokia.dempsy.messagetransport.Sender)1 SenderFactory (com.nokia.dempsy.messagetransport.SenderFactory)1 TcpTransport (com.nokia.dempsy.messagetransport.tcp.TcpTransport)1 BasicStatsCollector (com.nokia.dempsy.monitoring.basic.BasicStatsCollector)1 DecentralizedRoutingStrategy (com.nokia.dempsy.router.DecentralizedRoutingStrategy)1 SpecificClusterCheck (com.nokia.dempsy.router.SpecificClusterCheck)1 Histogram (com.yammer.metrics.core.Histogram)1 ArrayList (java.util.ArrayList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Before (org.junit.Before)1 Test (org.junit.Test)1