use of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector in project databus by linkedin.
the class TestDbusEventBufferMult method createStats.
private StatsCollectors<DbusEventsStatisticsCollector> createStats(String[] pNames) {
DbusEventsStatisticsCollector stats = new AggregatedDbusEventsStatisticsCollector(1, "test", true, true, null);
StatsCollectors<DbusEventsStatisticsCollector> statsColl = new StatsCollectors<DbusEventsStatisticsCollector>(stats);
int count = 1;
for (String pname : pNames) {
DbusEventsStatisticsCollector s = new DbusEventsStatisticsCollector(1, "test" + count, true, true, null);
statsColl.addStatsCollector(pname, s);
++count;
}
return statsColl;
}
use of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector in project databus by linkedin.
the class ReadEventsTestParams method readEventsBlocking.
private void readEventsBlocking(boolean invokeStartOnBuffer) throws Exception {
// Src Event producer
Vector<DbusEvent> srcTestEvents = new Vector<DbusEvent>();
// Dest Event consumer
Vector<DbusEvent> dstTestEvents = new Vector<DbusEvent>();
EventBufferTestInput blockingCapacityTest = new EventBufferTestInput();
final int numEvents = 5000;
// set sharedBufferSize to a value much smaller than total size required
blockingCapacityTest.setNumEvents(numEvents).setWindowSize(numEvents / 10).setSharedBufferSize(numEvents / 5).setStagingBufferSize(numEvents / 10).setIndexSize(numEvents / 10).setIndividualBufferSize(numEvents).setBatchSize(numEvents / 2).setProducerBufferSize(numEvents * 2).setConsQueuePolicy(QueuePolicy.BLOCK_ON_WRITE).setPayloadSize(100).setDeleteInterval(1).setTestName("readEventsBlocking(" + invokeStartOnBuffer + ")");
// set window size > shared buffer size ; shared buffer is still lower than total capacity
EventBufferTestInput block2 = new EventBufferTestInput();
block2.setNumEvents(numEvents).setWindowSize(numEvents / 4).setSharedBufferSize(numEvents / 5).setStagingBufferSize(numEvents / 5).setIndexSize(numEvents / 10).setIndividualBufferSize(numEvents).setBatchSize(numEvents).setProducerBufferSize(numEvents * 2).setConsQueuePolicy(QueuePolicy.BLOCK_ON_WRITE).setPayloadSize(100).setDeleteInterval(1);
// set staging buffer size = shared buffer size ; shared buffer is still lower than total capacity ;
EventBufferTestInput block3 = new EventBufferTestInput();
block3.setNumEvents(numEvents).setWindowSize(numEvents / 20).setSharedBufferSize(numEvents / 5).setStagingBufferSize(numEvents / 5).setIndexSize(numEvents / 10).setIndividualBufferSize(numEvents).setBatchSize(numEvents).setProducerBufferSize(numEvents * 2).setConsQueuePolicy(QueuePolicy.BLOCK_ON_WRITE).setPayloadSize(100).setDeleteInterval(1);
// Test configurations;
Vector<EventBufferTestInput> tests = new Vector<EventBufferTestInput>();
tests.add(blockingCapacityTest);
tests.add(block2);
tests.add(block3);
DbusEventsStatisticsCollector emitterStats = new DbusEventsStatisticsCollector(1, "appenderStats", true, true, null);
DbusEventsStatisticsCollector streamStats = new DbusEventsStatisticsCollector(1, "streamStats", true, true, null);
DbusEventsStatisticsCollector clientStats = new DbusEventsStatisticsCollector(1, "clientStats", true, true, null);
int testId = 0;
for (Iterator<EventBufferTestInput> it = tests.iterator(); it.hasNext(); ) {
EventBufferTestInput testInput = it.next();
srcTestEvents.clear();
dstTestEvents.clear();
emitterStats.reset();
streamStats.reset();
clientStats.reset();
assertEquals(0, dstTestEvents.size());
boolean result = runConstEventsReaderWriter(srcTestEvents, dstTestEvents, testInput, emitterStats, streamStats, clientStats, invokeStartOnBuffer);
LOG.info(String.format("TestId=%d Test=%s result=%b size of dst events=%d \n", testId, testInput.toString(), result, dstTestEvents.size()));
assertTrue(result);
checkEvents(srcTestEvents, dstTestEvents, numEvents);
++testId;
}
}
use of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector in project databus by linkedin.
the class TestDbusEventStatsCollectorPartitioner method testStatsCollectorPartitionerSingleDb.
@Test
public void testStatsCollectorPartitionerSingleDb() {
DbusEventStatsCollectorsPartitioner collector = new DbusEventStatsCollectorsPartitioner(1, ":inbound", null);
TestStatsCollectorCallback callback = new TestStatsCollectorCallback();
collector.registerStatsCallback(callback);
// Add 2 collectors for DB1
PhysicalPartition p1 = new PhysicalPartition(1, "db1");
PhysicalPartition p2 = new PhysicalPartition(2, "db1");
DbusEventsStatisticsCollector c1 = new DbusEventsStatisticsCollector(1, "db1:1", true, false, null);
DbusEventsStatisticsCollector c2 = new DbusEventsStatisticsCollector(1, "db1:2", true, false, null);
collector.addStatsCollector(p1, c1);
collector.addStatsCollector(p2, c2);
StatsWriter w1 = new StatsWriter(c1);
StatsWriter w2 = new StatsWriter(c2);
w1.addEvents(2, 2, 100);
w2.addEvents(2, 2, 200);
StatsCollectors<DbusEventsStatisticsCollector> col = collector.getDBStatsCollector("db1");
Assert.assertNotNull(col);
col.mergeStatsCollectors();
LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
LOG.info("C1 Stats : " + c1.getTotalStats());
LOG.info("C2 Stats : " + c2.getTotalStats());
DbusEventsTotalStats s = col.getStatsCollector().getTotalStats();
Assert.assertEquals("Total Events", 8, s.getNumDataEvents());
Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
Assert.assertEquals("Min Scn", 101, s.getMinScn());
Assert.assertEquals("Max Scn", 205, s.getMaxScn());
Assert.assertEquals("Num Stats Callback", 1, callback.getCollectorsAddedList().size());
collector.removeAllStatsCollector();
Assert.assertEquals("Num Stats Callback", 1, callback.getCollectorsRemovedList().size());
}
use of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector in project databus by linkedin.
the class TestDbusEventStatsCollectorPartitioner method testStatsCollectorPartitionerMultipleDbs.
@Test
public void testStatsCollectorPartitionerMultipleDbs() {
DbusEventStatsCollectorsPartitioner collector = new DbusEventStatsCollectorsPartitioner(1, ":inbound", null);
TestStatsCollectorCallback callback = new TestStatsCollectorCallback();
collector.registerStatsCallback(callback);
// Add 2 collectors for DB1
PhysicalPartition p1 = new PhysicalPartition(1, "db1");
PhysicalPartition p2 = new PhysicalPartition(2, "db1");
DbusEventsStatisticsCollector c1 = new DbusEventsStatisticsCollector(1, "db1:1", true, false, null);
DbusEventsStatisticsCollector c2 = new DbusEventsStatisticsCollector(1, "db1:2", true, false, null);
collector.addStatsCollector(p1, c1);
collector.addStatsCollector(p2, c2);
// Add 2 collectors for DB2
PhysicalPartition p3 = new PhysicalPartition(1, "db2");
PhysicalPartition p4 = new PhysicalPartition(2, "db2");
DbusEventsStatisticsCollector c3 = new DbusEventsStatisticsCollector(1, "db2:1", true, false, null);
DbusEventsStatisticsCollector c4 = new DbusEventsStatisticsCollector(1, "db2:2", true, false, null);
collector.addStatsCollector(p3, c3);
collector.addStatsCollector(p4, c4);
// Add 2 collectors for DB3
PhysicalPartition p5 = new PhysicalPartition(3, "db3");
PhysicalPartition p6 = new PhysicalPartition(4, "db3");
DbusEventsStatisticsCollector c5 = new DbusEventsStatisticsCollector(1, "db3:3", true, false, null);
DbusEventsStatisticsCollector c6 = new DbusEventsStatisticsCollector(1, "db3:4", true, false, null);
collector.addStatsCollector(p5, c5);
collector.addStatsCollector(p6, c6);
StatsWriter w1 = new StatsWriter(c1);
StatsWriter w2 = new StatsWriter(c2);
StatsWriter w3 = new StatsWriter(c3);
StatsWriter w4 = new StatsWriter(c4);
StatsWriter w5 = new StatsWriter(c5);
StatsWriter w6 = new StatsWriter(c6);
w1.addEvents(2, 2, 100);
w2.addEvents(2, 2, 200);
w3.addEvents(3, 2, 300);
w4.addEvents(3, 2, 400);
w5.addEvents(4, 2, 500);
w6.addEvents(4, 2, 600);
// Verify DB1 collector
StatsCollectors<DbusEventsStatisticsCollector> col = collector.getDBStatsCollector("db1");
Assert.assertNotNull(col);
col.mergeStatsCollectors();
LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
LOG.info("C1 Stats : " + c1.getTotalStats());
LOG.info("C2 Stats : " + c2.getTotalStats());
DbusEventsTotalStats s = col.getStatsCollector().getTotalStats();
Assert.assertEquals("Total Events", 8, s.getNumDataEvents());
Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
Assert.assertEquals("Min Scn", 101, s.getMinScn());
Assert.assertEquals("Max Scn", 205, s.getMaxScn());
// Verify DB2 collector
col = collector.getDBStatsCollector("db2");
Assert.assertNotNull(col);
col.mergeStatsCollectors();
LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
LOG.info("C3 Stats : " + c3.getTotalStats());
LOG.info("C4 Stats : " + c4.getTotalStats());
s = col.getStatsCollector().getTotalStats();
Assert.assertEquals("Total Events", 12, s.getNumDataEvents());
Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
Assert.assertEquals("Min Scn", 301, s.getMinScn());
Assert.assertEquals("Max Scn", 407, s.getMaxScn());
// Verify DB3 collector
col = collector.getDBStatsCollector("db3");
Assert.assertNotNull(col);
col.mergeStatsCollectors();
LOG.info("Merged Stats : " + col.getStatsCollector().getTotalStats());
LOG.info("C3 Stats : " + c5.getTotalStats());
LOG.info("C4 Stats : " + c6.getTotalStats());
s = col.getStatsCollector().getTotalStats();
Assert.assertEquals("Total Events", 16, s.getNumDataEvents());
Assert.assertEquals("Sys Events", 4, s.getNumSysEvents());
Assert.assertEquals("Min Scn", 501, s.getMinScn());
Assert.assertEquals("Max Scn", 609, s.getMaxScn());
Assert.assertEquals("Num Stats Callback", 3, callback.getCollectorsAddedList().size());
collector.removeAllStatsCollector();
Assert.assertEquals("Num Stats Callback", 3, callback.getCollectorsRemovedList().size());
}
use of com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector in project databus by linkedin.
the class HttpRelay method addPhysicalPartitionCollectors.
public void addPhysicalPartitionCollectors(PhysicalPartition pPartition) {
String statsCollectorName = pPartition.toSimpleString();
if (null != _inBoundStatsCollectors) {
synchronized (_inBoundStatsCollectors) {
if (null == _inBoundStatsCollectors.getStatsCollector(statsCollectorName)) {
DbusEventsStatisticsCollector collector = new DbusEventsStatisticsCollector(getContainerStaticConfig().getId(), statsCollectorName + ".inbound", true, false, getMbeanServer());
_inBoundStatsCollectors.addStatsCollector(statsCollectorName, collector);
_dbInboundStatsCollectors.addStatsCollector(pPartition, collector);
}
}
}
if (null != _outBoundStatsCollectors) {
synchronized (_outBoundStatsCollectors) {
if (null == _outBoundStatsCollectors.getStatsCollector(statsCollectorName)) {
DbusEventsStatisticsCollector collector = new DbusEventsStatisticsCollector(getContainerStaticConfig().getId(), statsCollectorName + ".outbound", true, false, getMbeanServer());
_outBoundStatsCollectors.addStatsCollector(statsCollectorName, collector);
_dbOutboundStatsCollectors.addStatsCollector(pPartition, collector);
}
}
}
}
Aggregations