use of com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector in project databus by linkedin.
the class DatabusV2ClusterRegistrationImpl method initializeStatsCollectors.
protected synchronized void initializeStatsCollectors() {
// some safety against null pointers coming from unit tests
MBeanServer mbeanServer = null;
int ownerId = -1;
long pullerThreadDeadnessThresholdMs = UnifiedClientStats.DEFAULT_DEADNESS_THRESHOLD_MS;
if (null != _client) {
mbeanServer = _client.getMbeanServer();
ownerId = _client.getContainerStaticConfig().getId();
pullerThreadDeadnessThresholdMs = _client.getClientStaticConfig().getPullerThreadDeadnessThresholdMs();
}
String regId = null != _id ? _id.getId() : "unknownReg";
ConsumerCallbackStats relayConsumerStats = new ConsumerCallbackStats(ownerId, regId + ".callback.relay", regId, true, false, new ConsumerCallbackStatsEvent());
ConsumerCallbackStats bootstrapConsumerStats = new ConsumerCallbackStats(ownerId, regId + ".callback.bootstrap", regId, true, false, new ConsumerCallbackStatsEvent());
UnifiedClientStats unifiedClientStats = new UnifiedClientStats(ownerId, regId + ".callback.unified", regId, true, false, pullerThreadDeadnessThresholdMs, new UnifiedClientStatsEvent());
_relayCallbackStatsMerger = new StatsCollectors<ConsumerCallbackStats>(relayConsumerStats);
_bootstrapCallbackStatsMerger = new StatsCollectors<ConsumerCallbackStats>(bootstrapConsumerStats);
_unifiedClientStatsMerger = new StatsCollectors<UnifiedClientStats>(unifiedClientStats);
_relayEventStatsMerger = new StatsCollectors<DbusEventsStatisticsCollector>(new AggregatedDbusEventsStatisticsCollector(ownerId, regId + ".inbound", true, false, mbeanServer));
_bootstrapEventStatsMerger = new StatsCollectors<DbusEventsStatisticsCollector>(new AggregatedDbusEventsStatisticsCollector(ownerId, regId + ".inbound.bs", true, false, mbeanServer));
if (null != _client) {
_client.getBootstrapEventsStats().addStatsCollector(regId, _bootstrapEventStatsMerger.getStatsCollector());
_client.getInBoundStatsCollectors().addStatsCollector(regId, _relayEventStatsMerger.getStatsCollector());
_client.getRelayConsumerStatsCollectors().addStatsCollector(regId, _relayCallbackStatsMerger.getStatsCollector());
_client.getBootstrapConsumerStatsCollectors().addStatsCollector(regId, _bootstrapCallbackStatsMerger.getStatsCollector());
_client.getUnifiedClientStatsCollectors().addStatsCollector(regId, _unifiedClientStatsMerger.getStatsCollector());
_client.getGlobalStatsMerger().registerStatsCollector(_relayEventStatsMerger);
_client.getGlobalStatsMerger().registerStatsCollector(_bootstrapEventStatsMerger);
_client.getGlobalStatsMerger().registerStatsCollector(_relayCallbackStatsMerger);
_client.getGlobalStatsMerger().registerStatsCollector(_bootstrapCallbackStatsMerger);
_client.getGlobalStatsMerger().registerStatsCollector(_unifiedClientStatsMerger);
}
}
use of com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector 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.AggregatedDbusEventsStatisticsCollector in project databus by linkedin.
the class TestAggregatedDbusEventStatsCollector method runAggregateTestStats.
void runAggregateTestStats(int n) {
try {
DbusEventsStatisticsCollector aggregateEventStatsCollectors = new AggregatedDbusEventsStatisticsCollector(0, "eventsInbound", true, true, null);
// collection of n+1 stats collectors;
StatsCollectors<DbusEventsStatisticsCollector> eventStatsCollectors = new StatsCollectors<DbusEventsStatisticsCollector>(aggregateEventStatsCollectors);
// add new individual stats collectors
int maxEventsInWindow = 10;
StatsWriter[] nStatsWriters = createStatsWriters(n, maxEventsInWindow);
for (StatsWriter sw : nStatsWriters) {
eventStatsCollectors.addStatsCollector(sw.getStatsName(), sw.getEventsStatsCollector());
}
// aggregator thread; 250 ms poll time
GlobalStatsCalc agg = new GlobalStatsCalc(10);
agg.registerStatsCollector(eventStatsCollectors);
Thread aggThread = new Thread(agg);
aggThread.start();
// start writers
for (StatsWriter sw : nStatsWriters) {
sw.start();
}
// Let the writers start
Thread.sleep(1000);
long startTimeMs = System.currentTimeMillis();
// 5s
long durationInMs = 5 * 1000;
DbusEventsTotalStats globalStats = aggregateEventStatsCollectors.getTotalStats();
long prevValue = 0, prevSize = 0;
while (System.currentTimeMillis() < (startTimeMs + durationInMs)) {
// constraint checks;
// check that readers don't have partial updates or get initialized
long value = globalStats.getNumDataEvents();
long size = globalStats.getSizeDataEvents();
Assert.assertTrue(value > 0);
if (prevValue > 0 && (value != prevValue)) {
Assert.assertTrue(size != prevSize);
prevValue = value;
prevSize = size;
}
Assert.assertTrue(globalStats.getMaxSeenWinScn() > 0);
Thread.sleep(RngUtils.randomPositiveInt() % 10 + 1);
}
// shut down
for (StatsWriter sw : nStatsWriters) {
sw.shutdown();
sw.interrupt();
}
// Give a chance to catch up
Thread.sleep(1000);
agg.halt();
aggThread.interrupt();
// final tally aggregatedEventTotalStats = sum of all individual statsWriter objects in a thread free way
AggregatedDbusEventsTotalStats myTotalStats = new AggregatedDbusEventsTotalStats(StatsWriter.OWNERID, "mytotal", true, false, null);
for (DbusEventsStatisticsCollector s : eventStatsCollectors.getStatsCollectors()) {
DbusEventsTotalStats writerStat = s.getTotalStats();
// obviously - we assume this is correct here. we want to check that the updates happen correctly in a concurrent setting
myTotalStats.mergeStats(writerStat);
}
LOG.info("global = " + globalStats.getNumDataEvents() + " Sigma writers=" + myTotalStats.getNumDataEvents());
Assert.assertEquals("NumDataEvents mismatch for n = " + n, globalStats.getNumDataEvents(), myTotalStats.getNumDataEvents());
Assert.assertEquals("MaxSeenWinScn mismatch for n = " + n, globalStats.getMaxSeenWinScn(), myTotalStats.getMaxSeenWinScn());
} catch (InterruptedException e) {
Assert.assertTrue(false);
}
}
Aggregations