Search in sources :

Example 1 with AggregatedDbusEventsStatisticsCollector

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);
    }
}
Also used : UnifiedClientStats(com.linkedin.databus.client.pub.mbean.UnifiedClientStats) ConsumerCallbackStats(com.linkedin.databus.client.pub.mbean.ConsumerCallbackStats) ConsumerCallbackStatsEvent(com.linkedin.databus.client.pub.monitoring.events.ConsumerCallbackStatsEvent) AggregatedDbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector) DbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector) AggregatedDbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector) Checkpoint(com.linkedin.databus.core.Checkpoint) UnifiedClientStatsEvent(com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent) MBeanServer(javax.management.MBeanServer)

Example 2 with AggregatedDbusEventsStatisticsCollector

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;
}
Also used : AggregatedDbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector) DbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector) AggregatedDbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector) StatsCollectors(com.linkedin.databus.core.monitoring.mbean.StatsCollectors)

Example 3 with AggregatedDbusEventsStatisticsCollector

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);
    }
}
Also used : AggregatedDbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector) AggregatedDbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector) DbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector) GlobalStatsCalc(com.linkedin.databus2.core.container.netty.ServerContainer.GlobalStatsCalc) StatsCollectors(com.linkedin.databus.core.monitoring.mbean.StatsCollectors) AggregatedDbusEventsTotalStats(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsTotalStats) DbusEventsTotalStats(com.linkedin.databus.core.monitoring.mbean.DbusEventsTotalStats) AggregatedDbusEventsTotalStats(com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsTotalStats)

Aggregations

AggregatedDbusEventsStatisticsCollector (com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector)3 DbusEventsStatisticsCollector (com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector)3 StatsCollectors (com.linkedin.databus.core.monitoring.mbean.StatsCollectors)2 ConsumerCallbackStats (com.linkedin.databus.client.pub.mbean.ConsumerCallbackStats)1 UnifiedClientStats (com.linkedin.databus.client.pub.mbean.UnifiedClientStats)1 ConsumerCallbackStatsEvent (com.linkedin.databus.client.pub.monitoring.events.ConsumerCallbackStatsEvent)1 UnifiedClientStatsEvent (com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent)1 Checkpoint (com.linkedin.databus.core.Checkpoint)1 AggregatedDbusEventsTotalStats (com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsTotalStats)1 DbusEventsTotalStats (com.linkedin.databus.core.monitoring.mbean.DbusEventsTotalStats)1 GlobalStatsCalc (com.linkedin.databus2.core.container.netty.ServerContainer.GlobalStatsCalc)1 MBeanServer (javax.management.MBeanServer)1