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;
}
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;
}
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;
}
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());
}
Aggregations