Package com.linkedin.databus.client.pub.mbean

Examples of com.linkedin.databus.client.pub.mbean.UnifiedClientStats


   */
  @Test
  public void testHistogramMetricsAggregationNonOverlappingRanges()
  {
    // create stats objects:  two low-level (per-connection) ones and one aggregator
    UnifiedClientStats unifiedClientStats1 = new UnifiedClientStats(1 /* ownerId */, "test1", "dim1");
    UnifiedClientStats unifiedClientStats2 = new UnifiedClientStats(2 /* ownerId */, "test2", "dim2");
    UnifiedClientStats unifiedClientStatsAgg = new UnifiedClientStats(99 /* ownerId */, "testAgg", "dimAgg");

    for (int i = 0; i < MergeableExponentiallyDecayingReservoir.DEFAULT_SIZE; ++i// 1028
    {
      // As noted in testBasicHistogramMetrics(), our dependence on System.currentTimeMillis() may lead
      // to some jitter in the data values for timeLagSourceToReceiptMs.
      long now = System.currentTimeMillis();
      long sourceTimestampNs1 = (now - 1000L - i) * DbusConstants.NUM_NSECS_IN_MSEC;
      long sourceTimestampNs2 = (now - 5000L - i) * DbusConstants.NUM_NSECS_IN_MSEC;

      long callbackTimeElapsedNs1 = (long)i * DbusConstants.NUM_NSECS_IN_MSEC;
      long callbackTimeElapsedNs2 = ((long)i + 2000L) * DbusConstants.NUM_NSECS_IN_MSEC;

      DbusEvent dbusEvent1 = createEvent(sourceTimestampNs1);
      DbusEvent dbusEvent2 = createEvent(sourceTimestampNs2);

      unifiedClientStats1.registerDataEventReceived(dbusEvent1);
      unifiedClientStats2.registerDataEventReceived(dbusEvent2);
      unifiedClientStats1.registerCallbacksProcessed(callbackTimeElapsedNs1);
      unifiedClientStats2.registerCallbacksProcessed(callbackTimeElapsedNs2);
    }

    unifiedClientStatsAgg.merge(unifiedClientStats1);
    unifiedClientStatsAgg.merge(unifiedClientStats2);

    // Expected timeLagConsumerCallbacksMs histogram values (exact):
    //   unifiedClientStats1:  0 to 1027 ms
    //   unifiedClientStats2:  2000 to 3027 ms

    assertEquals("unexpected timeLagConsumerCallbacksMs 50th percentile for connection #1",
                 513.5,
                 unifiedClientStats1.getTimeLagConsumerCallbacksMs_HistPct_50());
    assertEquals("unexpected timeLagConsumerCallbacksMs 50th percentile for connection #2",
                 2513.5,
                 unifiedClientStats2.getTimeLagConsumerCallbacksMs_HistPct_50());

    // The exact value depends on the relative fraction of '1' and '2' values that are retained in the
    // aggregate.  If equal, the value should be near 1513.5, but even then the exact value depends on
    // whether the 1027 and 2000 values get bumped out of the aggregate.  In the more common case that
    // the fractions retained are unequal, the median will fall between two values near the top end of
    // unifiedClientStats1 or near the bottom end of unifiedClientStats2.  An allowance of 100 either
    // way should be safe.
    double percentile = unifiedClientStatsAgg.getTimeLagConsumerCallbacksMs_HistPct_50();
    assertTrue("unexpected timeLagConsumerCallbacksMs 50th percentile for aggregated stats: " + percentile,
               927.0 <= percentile && percentile <= 2100.0);

    assertEquals("unexpected timeLagConsumerCallbacksMs max value for connection #1",
                 1027.0,
                 unifiedClientStats1.getTimeLagConsumerCallbacksMs_Max());
    assertEquals("unexpected timeLagConsumerCallbacksMs max value for connection #2",
                 3027.0,
                 unifiedClientStats2.getTimeLagConsumerCallbacksMs_Max());

    double max = unifiedClientStatsAgg.getTimeLagConsumerCallbacksMs_Max();
    assertTrue("unexpected timeLagConsumerCallbacksMs max value for aggregated stats: " + max,
               2000.0 <= max && max <= 3027.0)// nominal value is 3027.0

    // Expected timeLagSourceToReceiptMs histogram values (approximate):
    //   unifiedClientStats1:  1000 to 2027 ms
    //   unifiedClientStats2:  5000 to 6027 ms

    percentile = unifiedClientStats1.getTimeLagSourceToReceiptMs_HistPct_50();
    assertTrue("unexpected timeLagSourceToReceiptMs 50th percentile for connection #1: " + percentile,
               1512.5 <= percentile && percentile <= 1514.5);    // nominal value is 1513.5

    percentile = unifiedClientStats2.getTimeLagSourceToReceiptMs_HistPct_50();
    assertTrue("unexpected timeLagSourceToReceiptMs 50th percentile for connection #2: " + percentile,
               5512.5 <= percentile && percentile <= 5514.5);    // nominal value is 5513.5

    // same caveat as above:  the median depends strongly on the relative proportion of unifiedClientStats1
    // and unifiedClientStats2 data points retained in the aggregate, so the inequality is quite loose
    percentile = unifiedClientStatsAgg.getTimeLagSourceToReceiptMs_HistPct_50();
    assertTrue("unexpected timeLagSourceToReceiptMs 50th percentile for aggregated stats: " + percentile,
               1927.0 <= percentile && percentile <= 5100.0);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.databus.client.pub.mbean.UnifiedClientStats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.