Search in sources :

Example 1 with HerderMetrics

use of org.apache.kafka.connect.runtime.distributed.DistributedHerder.HerderMetrics in project apache-kafka-on-k8s by banzaicloud.

the class DistributedHerderTest method assertStatistics.

private void assertStatistics(String expectedLeader, boolean isRebalancing, int expectedEpoch, int completedRebalances, double rebalanceTime, double millisSinceLastRebalance) {
    HerderMetrics herderMetrics = herder.herderMetrics();
    MetricGroup group = herderMetrics.metricGroup();
    double epoch = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "epoch");
    String leader = MockConnectMetrics.currentMetricValueAsString(metrics, group, "leader-name");
    double rebalanceCompletedTotal = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "completed-rebalances-total");
    double rebalancing = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "rebalancing");
    double rebalanceTimeMax = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "rebalance-max-time-ms");
    double rebalanceTimeAvg = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "rebalance-avg-time-ms");
    double rebalanceTimeSinceLast = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "time-since-last-rebalance-ms");
    assertEquals(expectedEpoch, epoch, 0.0001d);
    assertEquals(expectedLeader, leader);
    assertEquals(completedRebalances, rebalanceCompletedTotal, 0.0001d);
    assertEquals(isRebalancing ? 1.0d : 0.0d, rebalancing, 0.0001d);
    assertEquals(millisSinceLastRebalance, rebalanceTimeSinceLast, 0.0001d);
    if (rebalanceTime <= 0L) {
        assertEquals(Double.NEGATIVE_INFINITY, rebalanceTimeMax, 0.0001d);
        assertEquals(0.0d, rebalanceTimeAvg, 0.0001d);
    } else {
        assertEquals(rebalanceTime, rebalanceTimeMax, 0.0001d);
        assertEquals(rebalanceTime, rebalanceTimeAvg, 0.0001d);
    }
}
Also used : MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup) HerderMetrics(org.apache.kafka.connect.runtime.distributed.DistributedHerder.HerderMetrics)

Example 2 with HerderMetrics

use of org.apache.kafka.connect.runtime.distributed.DistributedHerder.HerderMetrics in project kafka by apache.

the class DistributedHerderTest method assertStatistics.

private void assertStatistics(String expectedLeader, boolean isRebalancing, int expectedEpoch, int completedRebalances, double rebalanceTime, double millisSinceLastRebalance) {
    HerderMetrics herderMetrics = herder.herderMetrics();
    MetricGroup group = herderMetrics.metricGroup();
    double epoch = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "epoch");
    String leader = MockConnectMetrics.currentMetricValueAsString(metrics, group, "leader-name");
    double rebalanceCompletedTotal = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "completed-rebalances-total");
    double rebalancing = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "rebalancing");
    double rebalanceTimeMax = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "rebalance-max-time-ms");
    double rebalanceTimeAvg = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "rebalance-avg-time-ms");
    double rebalanceTimeSinceLast = MockConnectMetrics.currentMetricValueAsDouble(metrics, group, "time-since-last-rebalance-ms");
    assertEquals(expectedEpoch, epoch, 0.0001d);
    assertEquals(expectedLeader, leader);
    assertEquals(completedRebalances, rebalanceCompletedTotal, 0.0001d);
    assertEquals(isRebalancing ? 1.0d : 0.0d, rebalancing, 0.0001d);
    assertEquals(millisSinceLastRebalance, rebalanceTimeSinceLast, 0.0001d);
    if (rebalanceTime <= 0L) {
        assertEquals(Double.NaN, rebalanceTimeMax, 0.0001d);
        assertEquals(Double.NaN, rebalanceTimeAvg, 0.0001d);
    } else {
        assertEquals(rebalanceTime, rebalanceTimeMax, 0.0001d);
        assertEquals(rebalanceTime, rebalanceTimeAvg, 0.0001d);
    }
}
Also used : MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup) HerderMetrics(org.apache.kafka.connect.runtime.distributed.DistributedHerder.HerderMetrics)

Aggregations

MetricGroup (org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup)2 HerderMetrics (org.apache.kafka.connect.runtime.distributed.DistributedHerder.HerderMetrics)2