test_class.declarator: ctx = new HystrixRequestContextRule()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public HystrixRequestContextRule ctx = new HystrixRequestContextRule();
test_class.type: HystrixRequestContextRule
test_class.var_name: ctx
test_class.declarator: uniqueNameCounter = new AtomicInteger(1)
test_class.modifier: static
test_class.original_string: static AtomicInteger uniqueNameCounter = new AtomicInteger(1);
test_class.type: AtomicInteger
test_class.var_name: uniqueNameCounter
test_class.file: hystrix-core/src/test/java/com/netflix/hystrix/HystrixCommandTest.java
test_class.identifier: HystrixCommandTest
test_class.superclass: extends CommonHystrixCommandTests<TestHystrixCommand<Integer>>
test_case.body: @Test
      public void testSemaphorePermitsInUse() throws Exception {
          final TestCircuitBreaker circuitBreaker = new TestCircuitBreaker();
  
          // this semaphore will be shared across multiple command instances
          final TryableSemaphoreActual sharedSemaphore =
                  new TryableSemaphoreActual(HystrixProperty.Factory.asProperty(3));
  
          // used to wait until all commands have started
          final CountDownLatch startLatch = new CountDownLatch((sharedSemaphore.numberOfPermits.get() * 2) + 1);
  
          // used to signal that all command can finish
          final CountDownLatch sharedLatch = new CountDownLatch(1);
  
          // tracks failures to obtain semaphores
          final AtomicInteger failureCount = new AtomicInteger();
  
          final Runnable sharedSemaphoreRunnable = new HystrixContextRunnable(HystrixPlugins.getInstance().getConcurrencyStrategy(), new Runnable() {
              public void run() {
                  try {
                      new LatchedSemaphoreCommand("Command-Shared", circuitBreaker, sharedSemaphore, startLatch, sharedLatch).execute();
                  } catch (Exception e) {
                      startLatch.countDown();
                      e.printStackTrace();
                      failureCount.incrementAndGet();
                  }
              }
          });
  
          // creates group of threads each using command sharing a single semaphore
          // I create extra threads and commands so that I can verify that some of them fail to obtain a semaphore
          final int sharedThreadCount = sharedSemaphore.numberOfPermits.get() * 2;
          final Thread[] sharedSemaphoreThreads = new Thread[sharedThreadCount];
          for (int i = 0; i < sharedThreadCount; i++) {
              sharedSemaphoreThreads[i] = new Thread(sharedSemaphoreRunnable);
          }
  
          // creates thread using isolated semaphore
          final TryableSemaphoreActual isolatedSemaphore =
                  new TryableSemaphoreActual(HystrixProperty.Factory.asProperty(1));
  
          final CountDownLatch isolatedLatch = new CountDownLatch(1);
  
          final Thread isolatedThread = new Thread(new HystrixContextRunnable(HystrixPlugins.getInstance().getConcurrencyStrategy(), new Runnable() {
              public void run() {
                  try {
                      new LatchedSemaphoreCommand("Command-Isolated", circuitBreaker, isolatedSemaphore, startLatch, isolatedLatch).execute();
                  } catch (Exception e) {
                      startLatch.countDown();
                      e.printStackTrace();
                      failureCount.incrementAndGet();
                  }
              }
          }));
  
          // verifies no permits in use before starting threads
          assertEquals("before threads start, shared semaphore should be unused", 0, sharedSemaphore.getNumberOfPermitsUsed());
          assertEquals("before threads start, isolated semaphore should be unused", 0, isolatedSemaphore.getNumberOfPermitsUsed());
  
          for (int i = 0; i < sharedThreadCount; i++) {
              sharedSemaphoreThreads[i].start();
          }
          isolatedThread.start();
  
          // waits until all commands have started
          startLatch.await(1000, TimeUnit.MILLISECONDS);
  
          // verifies that all semaphores are in use
          assertEquals("immediately after command start, all shared semaphores should be in-use",
                  sharedSemaphore.numberOfPermits.get().longValue(), sharedSemaphore.getNumberOfPermitsUsed());
          assertEquals("immediately after command start, isolated semaphore should be in-use",
                  isolatedSemaphore.numberOfPermits.get().longValue(), isolatedSemaphore.getNumberOfPermitsUsed());
  
          // signals commands to finish
          sharedLatch.countDown();
          isolatedLatch.countDown();
  
          for (int i = 0; i < sharedThreadCount; i++) {
              sharedSemaphoreThreads[i].join();
          }
          isolatedThread.join();
  
          // verifies no permits in use after finishing threads
          System.out.println("REQLOG : " + HystrixRequestLog.getCurrentRequest().getExecutedCommandsAsString());
  
          assertEquals("after all threads have finished, no shared semaphores should be in-use", 0, sharedSemaphore.getNumberOfPermitsUsed());
          assertEquals("after all threads have finished, isolated semaphore not in-use", 0, isolatedSemaphore.getNumberOfPermitsUsed());
  
          // verifies that some executions failed
          assertEquals("expected some of shared semaphore commands to get rejected", sharedSemaphore.numberOfPermits.get().longValue(), failureCount.get());
          assertEquals(0, circuitBreaker.metrics.getCurrentConcurrentExecutionCount());
      }
test_case.class_method_signature: HystrixCommandTest.testSemaphorePermitsInUse()
test_case.full_signature: @Test public void testSemaphorePermitsInUse()
test_case.identifier: testSemaphorePermitsInUse
test_case.invocations: asProperty get getConcurrencyStrategy getInstance execute countDown printStackTrace incrementAndGet get asProperty getConcurrencyStrategy getInstance execute countDown printStackTrace incrementAndGet assertEquals getNumberOfPermitsUsed assertEquals getNumberOfPermitsUsed start start await assertEquals longValue get getNumberOfPermitsUsed assertEquals longValue get getNumberOfPermitsUsed countDown countDown join join println getExecutedCommandsAsString getCurrentRequest assertEquals getNumberOfPermitsUsed assertEquals getNumberOfPermitsUsed assertEquals longValue get get assertEquals getCurrentConcurrentExecutionCount
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSemaphorePermitsInUse()
focal_class.declarator: executionThread = new AtomicReference<Thread>()
focal_class.modifier: private final
focal_class.original_string: private final AtomicReference<Thread> executionThread = new AtomicReference<Thread>();
focal_class.type: AtomicReference<Thread>
focal_class.var_name: executionThread
focal_class.declarator: interruptOnFutureCancel = new AtomicBoolean(false)
focal_class.modifier: private final
focal_class.original_string: private final AtomicBoolean interruptOnFutureCancel = new AtomicBoolean(false);
focal_class.type: AtomicBoolean
focal_class.var_name: interruptOnFutureCancel
focal_class.file: hystrix-core/src/main/java/com/netflix/hystrix/HystrixCommand.java
focal_class.identifier: HystrixCommand
focal_class.interfaces: implements HystrixExecutable<R>, HystrixInvokableInfo<R>, HystrixObservable<R>
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.full_signature: protected  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, HystrixThreadPoolKey threadPool, int executionIsolationThreadTimeoutInMilliseconds)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(Setter setter)
focal_class.full_signature: protected  HystrixCommand(Setter setter)
focal_class.identifier: HystrixCommand
focal_class.modifiers: protected
focal_class.parameters: (Setter setter)
focal_class.signature:  HystrixCommand(Setter setter)
focal_class.class_method_signature: HystrixCommand.HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.full_signature:   HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.identifier: HystrixCommand
focal_class.parameters: (HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.signature:  HystrixCommand(HystrixCommandGroupKey group, HystrixCommandKey key, HystrixThreadPoolKey threadPoolKey, HystrixCircuitBreaker circuitBreaker, HystrixThreadPool threadPool,
              HystrixCommandProperties.Setter commandPropertiesDefaults, HystrixThreadPoolProperties.Setter threadPoolPropertiesDefaults,
              HystrixCommandMetrics metrics, TryableSemaphore fallbackSemaphore, TryableSemaphore executionSemaphore,
              HystrixPropertiesStrategy propertiesStrategy, HystrixCommandExecutionHook executionHook)
focal_class.class_method_signature: HystrixCommand.run()
focal_class.full_signature: protected abstract R run()
focal_class.identifier: run
focal_class.modifiers: protected abstract
focal_class.parameters: ()
focal_class.return: R
focal_class.signature: R run()
focal_class.class_method_signature: HystrixCommand.getFallback()
focal_class.full_signature: protected R getFallback()
focal_class.identifier: getFallback
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: R
focal_class.signature: R getFallback()
focal_class.class_method_signature: HystrixCommand.getExecutionObservable()
focal_class.full_signature: @Override final protected Observable<R> getExecutionObservable()
focal_class.identifier: getExecutionObservable
focal_class.modifiers: @Override final protected
focal_class.parameters: ()
focal_class.return: Observable<R>
focal_class.signature: Observable<R> getExecutionObservable()
focal_class.class_method_signature: HystrixCommand.getFallbackObservable()
focal_class.full_signature: @Override final protected Observable<R> getFallbackObservable()
focal_class.identifier: getFallbackObservable
focal_class.modifiers: @Override final protected
focal_class.parameters: ()
focal_class.return: Observable<R>
focal_class.signature: Observable<R> getFallbackObservable()
focal_class.class_method_signature: HystrixCommand.execute()
focal_class.full_signature: public R execute()
focal_class.identifier: execute
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: R
focal_class.signature: R execute()
focal_class.class_method_signature: HystrixCommand.queue()
focal_class.full_signature: public Future<R> queue()
focal_class.identifier: queue
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Future<R>
focal_class.signature: Future<R> queue()
focal_class.class_method_signature: HystrixCommand.getFallbackMethodName()
focal_class.full_signature: @Override protected String getFallbackMethodName()
focal_class.identifier: getFallbackMethodName
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getFallbackMethodName()
focal_class.class_method_signature: HystrixCommand.isFallbackUserDefined()
focal_class.full_signature: @Override protected boolean isFallbackUserDefined()
focal_class.identifier: isFallbackUserDefined
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isFallbackUserDefined()
focal_class.class_method_signature: HystrixCommand.commandIsScalar()
focal_class.full_signature: @Override protected boolean commandIsScalar()
focal_class.identifier: commandIsScalar
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean commandIsScalar()
focal_class.superclass: extends AbstractCommand<R>
focal_method.body: public R execute() {
          try {
              return queue().get();
          } catch (Exception e) {
              throw Exceptions.sneakyThrow(decomposeException(e));
          }
      }
focal_method.class_method_signature: HystrixCommand.execute()
focal_method.full_signature: public R execute()
focal_method.identifier: execute
focal_method.invocations: get queue sneakyThrow decomposeException
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: R
focal_method.signature: R execute()