Search in sources :

Example 1 with UnifiedClientStatsEvent

use of com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent in project databus by linkedin.

the class UnifiedClientStats method doMergeStats.

// called by superclass's (AbstractMonitoringMBean's) mergeStats() and by
// StatsCollectors.mergeStatsCollectors() -> resetAndMerge() -> merge(); callers
// handle locking
@Override
protected void doMergeStats(Object eventData) {
    if (!(eventData instanceof UnifiedClientStats)) {
        LOG.warn("Attempt to merge stats from unknown event class: " + eventData.getClass().getName());
        return;
    }
    UnifiedClientStats otherEvent = (UnifiedClientStats) eventData;
    UnifiedClientStatsEvent e = otherEvent._event;
    _event.aggregated = true;
    // standalone metrics; aggregation = simple sum:
    _event.curBootstrappingPartitions += e.curBootstrappingPartitions;
    _event.numConsumerErrors += e.numConsumerErrors;
    _event.numDataEvents += e.numDataEvents;
    // special-case, half-standalone/half-derived metric:  aggregation is slightly complicated...
    if (e.aggregated) {
        // we're the third (or higher) level up, so it's safe to trust the lower level's count; just add it in:
        _event.curDeadConnections += e.curDeadConnections;
    } else if (System.currentTimeMillis() - e.timestampOfLastHeartbeatMs > _deadnessThresholdMs) {
        // we're the second level (first level of aggregation), so we need to check the first level's timestamp
        // to see if its connection is dead
        ++_event.curDeadConnections;
    }
    // (i.e., maximum interval), want _minimum_ (oldest) non-zero timestamp:
    if (_event.timestampLastDataEventWasReceivedMs == 0) {
        // other one is same or better, so assign unconditionally
        _event.timestampLastDataEventWasReceivedMs = e.timestampLastDataEventWasReceivedMs;
    } else if (e.timestampLastDataEventWasReceivedMs > 0) {
        // both are non-zero, so assign minimum
        _event.timestampLastDataEventWasReceivedMs = Math.min(_event.timestampLastDataEventWasReceivedMs, e.timestampLastDataEventWasReceivedMs);
    }
    // will be zero, so skip merge in that case.
    if (e.timestampLastDataEventWasReceivedMs > 0) {
        // we're an aggregate, so _reservoirTimeLagSourceToReceiptMs should never be null (aggregates can't bootstrap)
        _reservoirTimeLagSourceToReceiptMs.merge(otherEvent.getReservoirTimeLagSourceToReceiptMs());
    }
    // Support for timeLagConsumerCallbacksMs histogram metrics, which uses exponentially weighted statistical
    // sampling; aggregation is tricky (see MergeableExponentiallyDecayingReservoir for details).  No special
    // handling for bootstrap mode is needed.  If no callbacks have occurred, reservoirs will be empty, and all
    // percentile values will be zero (see getTimeLagConsumerCallbacksMs_HistPct() below).
    _reservoirTimeLagConsumerCallbacksMs.merge(otherEvent.getReservoirTimeLagConsumerCallbacksMs());
}
Also used : UnifiedClientStatsEvent(com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent)

Example 2 with UnifiedClientStatsEvent

use of com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent 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 3 with UnifiedClientStatsEvent

use of com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent in project databus by linkedin.

the class DatabusV2RegistrationImpl method initializeStatsCollectors.

/**
   * Initialize Statistics Collectors
   */
protected void initializeStatsCollectors(String regId, int ownerId, MBeanServer mbeanServer) {
    _inboundEventsStatsCollector = new DbusEventsStatisticsCollector(ownerId, regId + STREAM_EVENT_STATS_SUFFIX_NAME, true, false, mbeanServer);
    _bootstrapEventsStatsCollector = new DbusEventsStatisticsCollector(ownerId, regId + BOOTSTRAP_EVENT_STATS_SUFFIX_NAME, true, false, mbeanServer);
    _relayConsumerStats = new ConsumerCallbackStats(ownerId, regId + RELAY_CONSUMER_STATS_SUFFIX_NAME, regId, true, false, new ConsumerCallbackStatsEvent());
    _bootstrapConsumerStats = new ConsumerCallbackStats(ownerId, regId + BOOTSTRAP_CONSUMER_STATS_SUFFIX_NAME, regId, true, false, new ConsumerCallbackStatsEvent());
    _unifiedClientStats = new UnifiedClientStats(ownerId, regId + UNIFIED_CLIENT_STATS_SUFFIX_NAME, regId, true, false, _client.getClientStaticConfig().getPullerThreadDeadnessThresholdMs(), new UnifiedClientStatsEvent());
}
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) DbusEventsStatisticsCollector(com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector) UnifiedClientStatsEvent(com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent)

Aggregations

UnifiedClientStatsEvent (com.linkedin.databus.client.pub.monitoring.events.UnifiedClientStatsEvent)3 ConsumerCallbackStats (com.linkedin.databus.client.pub.mbean.ConsumerCallbackStats)2 UnifiedClientStats (com.linkedin.databus.client.pub.mbean.UnifiedClientStats)2 ConsumerCallbackStatsEvent (com.linkedin.databus.client.pub.monitoring.events.ConsumerCallbackStatsEvent)2 DbusEventsStatisticsCollector (com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector)2 Checkpoint (com.linkedin.databus.core.Checkpoint)1 AggregatedDbusEventsStatisticsCollector (com.linkedin.databus.core.monitoring.mbean.AggregatedDbusEventsStatisticsCollector)1 MBeanServer (javax.management.MBeanServer)1