test_class.declarator: stream
test_class.original_string: RollingCommandLatencyDistributionStream stream;
test_class.type: RollingCommandLatencyDistributionStream
test_class.var_name: stream
test_class.declarator: context
test_class.original_string: HystrixRequestContext context;
test_class.type: HystrixRequestContext
test_class.var_name: context
test_class.declarator: groupKey = HystrixCommandGroupKey.Factory.asKey("CommandLatency")
test_class.modifier: static
test_class.original_string: static HystrixCommandGroupKey groupKey = HystrixCommandGroupKey.Factory.asKey("CommandLatency");
test_class.type: HystrixCommandGroupKey
test_class.var_name: groupKey
test_class.file: hystrix-core/src/test/java/com/netflix/hystrix/metric/consumer/RollingCommandLatencyDistributionStreamTest.java
test_class.identifier: RollingCommandLatencyDistributionStreamTest
test_class.superclass: extends CommandStreamTest
test_case.body: @Test
      public void testMultipleBucketsBothGetStoredAndThenAgeOut() {
          HystrixCommandKey key = HystrixCommandKey.Factory.asKey("CMD-Latency-I");
          stream = RollingCommandLatencyDistributionStream.getInstance(key, 10, 100);
          stream.startCachingStreamValuesIfUnstarted();
  
          final CountDownLatch latch = new CountDownLatch(1);
          stream.observe().take(30).subscribe(new Subscriber<CachedValuesHistogram>() {
              @Override
              public void onCompleted() {
                  latch.countDown();
              }
  
              @Override
              public void onError(Throwable e) {
                  fail(e.getMessage());
              }
  
              @Override
              public void onNext(CachedValuesHistogram distribution) {
                  System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " Received distribution with count : " + distribution.getTotalCount() + " and mean : " + distribution.getMean());
                  if (distribution.getTotalCount() == 2) {
                      assertBetween(55, 90, (int) distribution.getMean());
                  }
                  if (distribution.getTotalCount() == 5) {
                      assertEquals(60, 90, (long) distribution.getMean());
                  }
              }
          });
  
          Command cmd1 = Command.from(groupKey, key, HystrixEventType.SUCCESS, 10);
          Command cmd2 = Command.from(groupKey, key, HystrixEventType.FAILURE, 100);
  
          cmd1.observe();
          cmd2.observe();
  
          try {
              Thread.sleep(500);
          } catch (InterruptedException ie) {
              fail("Interrupted ex");
          }
  
          Command cmd3 = Command.from(groupKey, key, HystrixEventType.SUCCESS, 60);
          Command cmd4 = Command.from(groupKey, key, HystrixEventType.SUCCESS, 60);
          Command cmd5 = Command.from(groupKey, key, HystrixEventType.SUCCESS, 70);
  
          cmd3.observe();
          cmd4.observe();
          cmd5.observe();
  
  
          try {
              assertTrue(latch.await(10000, TimeUnit.MILLISECONDS));
          } catch (InterruptedException ex) {
              fail("Interrupted ex");
          }
  
          assertEquals(0, stream.getLatest().getTotalCount());
      }
test_case.class_method_signature: RollingCommandLatencyDistributionStreamTest.testMultipleBucketsBothGetStoredAndThenAgeOut()
test_case.full_signature: @Test public void testMultipleBucketsBothGetStoredAndThenAgeOut()
test_case.identifier: testMultipleBucketsBothGetStoredAndThenAgeOut
test_case.invocations: asKey getInstance startCachingStreamValuesIfUnstarted subscribe take observe countDown fail getMessage println currentTimeMillis getName currentThread getTotalCount getMean getTotalCount assertBetween getMean getTotalCount assertEquals getMean from from observe observe sleep fail from from from observe observe observe assertTrue await fail assertEquals getTotalCount getLatest
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMultipleBucketsBothGetStoredAndThenAgeOut()
focal_class.declarator: streams = new ConcurrentHashMap<String, RollingCommandLatencyDistributionStream>()
focal_class.modifier: private static final
focal_class.original_string: private static final ConcurrentMap<String, RollingCommandLatencyDistributionStream> streams = new ConcurrentHashMap<String, RollingCommandLatencyDistributionStream>();
focal_class.type: ConcurrentMap<String, RollingCommandLatencyDistributionStream>
focal_class.var_name: streams
focal_class.declarator: addValuesToBucket = new Func2<Histogram, HystrixCommandCompletion, Histogram>() {
          @Override
          public Histogram call(Histogram initialDistribution, HystrixCommandCompletion event) {
              if (event.didCommandExecute() && event.getExecutionLatency() > -1) {
                  initialDistribution.recordValue(event.getExecutionLatency());
              }
              return initialDistribution;
          }
      }
focal_class.modifier: private static final
focal_class.original_string: private static final Func2<Histogram, HystrixCommandCompletion, Histogram> addValuesToBucket = new Func2<Histogram, HystrixCommandCompletion, Histogram>() {
          @Override
          public Histogram call(Histogram initialDistribution, HystrixCommandCompletion event) {
              if (event.didCommandExecute() && event.getExecutionLatency() > -1) {
                  initialDistribution.recordValue(event.getExecutionLatency());
              }
              return initialDistribution;
          }
      };
focal_class.type: Func2<Histogram, HystrixCommandCompletion, Histogram>
focal_class.var_name: addValuesToBucket
focal_class.file: hystrix-core/src/main/java/com/netflix/hystrix/metric/consumer/RollingCommandLatencyDistributionStream.java
focal_class.identifier: RollingCommandLatencyDistributionStream
focal_class.class_method_signature: RollingCommandLatencyDistributionStream.getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.full_signature: public static RollingCommandLatencyDistributionStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: (HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.return: RollingCommandLatencyDistributionStream
focal_class.signature: RollingCommandLatencyDistributionStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.class_method_signature: RollingCommandLatencyDistributionStream.getInstance(HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs)
focal_class.full_signature: public static RollingCommandLatencyDistributionStream getInstance(HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs)
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: (HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs)
focal_class.return: RollingCommandLatencyDistributionStream
focal_class.signature: RollingCommandLatencyDistributionStream getInstance(HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs)
focal_class.class_method_signature: RollingCommandLatencyDistributionStream.reset()
focal_class.full_signature: public static void reset()
focal_class.identifier: reset
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void reset()
focal_class.class_method_signature: RollingCommandLatencyDistributionStream.RollingCommandLatencyDistributionStream(HystrixCommandKey commandKey, int numPercentileBuckets, int percentileBucketSizeInMs)
focal_class.full_signature: private  RollingCommandLatencyDistributionStream(HystrixCommandKey commandKey, int numPercentileBuckets, int percentileBucketSizeInMs)
focal_class.identifier: RollingCommandLatencyDistributionStream
focal_class.modifiers: private
focal_class.parameters: (HystrixCommandKey commandKey, int numPercentileBuckets, int percentileBucketSizeInMs)
focal_class.signature:  RollingCommandLatencyDistributionStream(HystrixCommandKey commandKey, int numPercentileBuckets, int percentileBucketSizeInMs)
focal_class.superclass: extends RollingDistributionStream<HystrixCommandCompletion>
focal_method.body: public static RollingCommandLatencyDistributionStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties) {
          final int percentileMetricWindow = properties.metricsRollingPercentileWindowInMilliseconds().get();
          final int numPercentileBuckets = properties.metricsRollingPercentileWindowBuckets().get();
          final int percentileBucketSizeInMs = percentileMetricWindow / numPercentileBuckets;
  
          return getInstance(commandKey, numPercentileBuckets, percentileBucketSizeInMs);
      }
focal_method.class_method_signature: RollingCommandLatencyDistributionStream.getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_method.full_signature: public static RollingCommandLatencyDistributionStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_method.identifier: getInstance
focal_method.invocations: get metricsRollingPercentileWindowInMilliseconds get metricsRollingPercentileWindowBuckets getInstance
focal_method.modifiers: public static
focal_method.parameters: (HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_method.return: RollingCommandLatencyDistributionStream
focal_method.signature: RollingCommandLatencyDistributionStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)