test_class.declarator: context
test_class.original_string: HystrixRequestContext context;
test_class.type: HystrixRequestContext
test_class.var_name: context
test_class.declarator: stream
test_class.original_string: HealthCountsStream stream;
test_class.type: HealthCountsStream
test_class.var_name: stream
test_class.declarator: groupKey = HystrixCommandGroupKey.Factory.asKey("HealthCounts")
test_class.modifier: static
test_class.original_string: static HystrixCommandGroupKey groupKey = HystrixCommandGroupKey.Factory.asKey("HealthCounts");
test_class.type: HystrixCommandGroupKey
test_class.var_name: groupKey
test_class.file: hystrix-core/src/test/java/com/netflix/hystrix/metric/consumer/HealthCountsStreamTest.java
test_class.identifier: HealthCountsStreamTest
test_class.superclass: extends CommandStreamTest
test_case.body: @Test
      public void testSharedSourceStream() throws InterruptedException {
          HystrixCommandKey key = HystrixCommandKey.Factory.asKey("CMD-Health-N");
          stream = HealthCountsStream.getInstance(key, 10, 100);
  
          final CountDownLatch latch = new CountDownLatch(1);
          final AtomicBoolean allEqual = new AtomicBoolean(false);
  
          Observable<HystrixCommandMetrics.HealthCounts> o1 = stream
                  .observe()
                  .take(10)
                  .observeOn(Schedulers.computation());
  
          Observable<HystrixCommandMetrics.HealthCounts> o2 = stream
                  .observe()
                  .take(10)
                  .observeOn(Schedulers.computation());
  
          Observable<Boolean> zipped = Observable.zip(o1, o2, new Func2<HystrixCommandMetrics.HealthCounts, HystrixCommandMetrics.HealthCounts, Boolean>() {
              @Override
              public Boolean call(HystrixCommandMetrics.HealthCounts healthCounts, HystrixCommandMetrics.HealthCounts healthCounts2) {
                  return healthCounts == healthCounts2;  //we want object equality
              }
          });
          Observable < Boolean > reduced = zipped.reduce(true, new Func2<Boolean, Boolean, Boolean>() {
              @Override
              public Boolean call(Boolean a, Boolean b) {
                  return a && b;
              }
          });
  
          reduced.subscribe(new Subscriber<Boolean>() {
              @Override
              public void onCompleted() {
                  System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " Reduced OnCompleted");
                  latch.countDown();
              }
  
              @Override
              public void onError(Throwable e) {
                  System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " Reduced OnError : " + e);
                  e.printStackTrace();
                  latch.countDown();
              }
  
              @Override
              public void onNext(Boolean b) {
                  System.out.println(System.currentTimeMillis() + " : " + Thread.currentThread().getName() + " Reduced OnNext : " + b);
                  allEqual.set(b);
              }
          });
  
          for (int i = 0; i < 10; i++) {
              HystrixCommand<Integer> cmd = CommandStreamTest.Command.from(groupKey, key, HystrixEventType.SUCCESS, 20);
              cmd.execute();
          }
  
          assertTrue(latch.await(10000, TimeUnit.MILLISECONDS));
          assertTrue(allEqual.get());
          //we should be getting the same object from both streams.  this ensures that multiple subscribers don't induce extra work
      }
test_case.class_method_signature: HealthCountsStreamTest.testSharedSourceStream()
test_case.full_signature: @Test public void testSharedSourceStream()
test_case.identifier: testSharedSourceStream
test_case.invocations: asKey getInstance observeOn take observe computation observeOn take observe computation zip reduce subscribe println currentTimeMillis getName currentThread countDown println currentTimeMillis getName currentThread printStackTrace countDown println currentTimeMillis getName currentThread set from execute assertTrue await assertTrue get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSharedSourceStream()
focal_class.declarator: streams = new ConcurrentHashMap<String, HealthCountsStream>()
focal_class.modifier: private static final
focal_class.original_string: private static final ConcurrentMap<String, HealthCountsStream> streams = new ConcurrentHashMap<String, HealthCountsStream>();
focal_class.type: ConcurrentMap<String, HealthCountsStream>
focal_class.var_name: streams
focal_class.declarator: NUM_EVENT_TYPES = HystrixEventType.values().length
focal_class.modifier: private static final
focal_class.original_string: private static final int NUM_EVENT_TYPES = HystrixEventType.values().length;
focal_class.type: int
focal_class.var_name: NUM_EVENT_TYPES
focal_class.declarator: healthCheckAccumulator = new Func2<HystrixCommandMetrics.HealthCounts, long[], HystrixCommandMetrics.HealthCounts>() {
          @Override
          public HystrixCommandMetrics.HealthCounts call(HystrixCommandMetrics.HealthCounts healthCounts, long[] bucketEventCounts) {
              return healthCounts.plus(bucketEventCounts);
          }
      }
focal_class.modifier: private static final
focal_class.original_string: private static final Func2<HystrixCommandMetrics.HealthCounts, long[], HystrixCommandMetrics.HealthCounts> healthCheckAccumulator = new Func2<HystrixCommandMetrics.HealthCounts, long[], HystrixCommandMetrics.HealthCounts>() {
          @Override
          public HystrixCommandMetrics.HealthCounts call(HystrixCommandMetrics.HealthCounts healthCounts, long[] bucketEventCounts) {
              return healthCounts.plus(bucketEventCounts);
          }
      };
focal_class.type: Func2<HystrixCommandMetrics.HealthCounts, long[], HystrixCommandMetrics.HealthCounts>
focal_class.var_name: healthCheckAccumulator
focal_class.file: hystrix-core/src/main/java/com/netflix/hystrix/metric/consumer/HealthCountsStream.java
focal_class.identifier: HealthCountsStream
focal_class.class_method_signature: HealthCountsStream.getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.full_signature: public static HealthCountsStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: (HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.return: HealthCountsStream
focal_class.signature: HealthCountsStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_class.class_method_signature: HealthCountsStream.getInstance(HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs)
focal_class.full_signature: public static HealthCountsStream 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: HealthCountsStream
focal_class.signature: HealthCountsStream getInstance(HystrixCommandKey commandKey, int numBuckets, int bucketSizeInMs)
focal_class.class_method_signature: HealthCountsStream.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: HealthCountsStream.removeByKey(HystrixCommandKey key)
focal_class.full_signature: public static void removeByKey(HystrixCommandKey key)
focal_class.identifier: removeByKey
focal_class.modifiers: public static
focal_class.parameters: (HystrixCommandKey key)
focal_class.return: void
focal_class.signature: void removeByKey(HystrixCommandKey key)
focal_class.class_method_signature: HealthCountsStream.HealthCountsStream(final HystrixCommandKey commandKey, final int numBuckets, final int bucketSizeInMs,
                                 Func2<long[], HystrixCommandCompletion, long[]> reduceCommandCompletion)
focal_class.full_signature: private  HealthCountsStream(final HystrixCommandKey commandKey, final int numBuckets, final int bucketSizeInMs,
                                 Func2<long[], HystrixCommandCompletion, long[]> reduceCommandCompletion)
focal_class.identifier: HealthCountsStream
focal_class.modifiers: private
focal_class.parameters: (final HystrixCommandKey commandKey, final int numBuckets, final int bucketSizeInMs,
                                 Func2<long[], HystrixCommandCompletion, long[]> reduceCommandCompletion)
focal_class.signature:  HealthCountsStream(final HystrixCommandKey commandKey, final int numBuckets, final int bucketSizeInMs,
                                 Func2<long[], HystrixCommandCompletion, long[]> reduceCommandCompletion)
focal_class.class_method_signature: HealthCountsStream.getEmptyBucketSummary()
focal_class.full_signature: @Override long[] getEmptyBucketSummary()
focal_class.identifier: getEmptyBucketSummary
focal_class.modifiers: @Override
focal_class.parameters: ()
focal_class.return: long[]
focal_class.signature: long[] getEmptyBucketSummary()
focal_class.class_method_signature: HealthCountsStream.getEmptyOutputValue()
focal_class.full_signature: @Override HystrixCommandMetrics.HealthCounts getEmptyOutputValue()
focal_class.identifier: getEmptyOutputValue
focal_class.modifiers: @Override
focal_class.parameters: ()
focal_class.return: HystrixCommandMetrics.HealthCounts
focal_class.signature: HystrixCommandMetrics.HealthCounts getEmptyOutputValue()
focal_class.superclass: extends BucketedRollingCounterStream<HystrixCommandCompletion, long[], HystrixCommandMetrics.HealthCounts>
focal_method.body: public static HealthCountsStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties) {
          final int healthCountBucketSizeInMs = properties.metricsHealthSnapshotIntervalInMilliseconds().get();
          if (healthCountBucketSizeInMs == 0) {
              throw new RuntimeException("You have set the bucket size to 0ms.  Please set a positive number, so that the metric stream can be properly consumed");
          }
          final int numHealthCountBuckets = properties.metricsRollingStatisticalWindowInMilliseconds().get() / healthCountBucketSizeInMs;
  
          return getInstance(commandKey, numHealthCountBuckets, healthCountBucketSizeInMs);
      }
focal_method.class_method_signature: HealthCountsStream.getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_method.full_signature: public static HealthCountsStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_method.identifier: getInstance
focal_method.invocations: get metricsHealthSnapshotIntervalInMilliseconds get metricsRollingStatisticalWindowInMilliseconds getInstance
focal_method.modifiers: public static
focal_method.parameters: (HystrixCommandKey commandKey, HystrixCommandProperties properties)
focal_method.return: HealthCountsStream
focal_method.signature: HealthCountsStream getInstance(HystrixCommandKey commandKey, HystrixCommandProperties properties)