test_class.declarator: infoService
test_class.modifier: private
test_class.original_string: private AsyncIndexInfoService infoService;
test_class.type: AsyncIndexInfoService
test_class.var_name: infoService
test_class.declarator: statsMBean = mock(IndexStatsMBean.class)
test_class.modifier: private
test_class.original_string: private IndexStatsMBean statsMBean = mock(IndexStatsMBean.class);
test_class.type: IndexStatsMBean
test_class.var_name: statsMBean
test_class.file: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/importer/AbortingIndexerLockTest.java
test_class.identifier: AbortingIndexerLockTest
test_case.body: @Test
      public void lockTimedout() throws Exception{
          Clock.Virtual clock = new Clock.Virtual();
          AbortingIndexerLock lock = new AbortingIndexerLock(infoService, clock);
  
          when(statsMBean.getStatus())
                  .thenReturn(IndexStatsMBean.STATUS_RUNNING)
                  .thenReturn(IndexStatsMBean.STATUS_RUNNING)
                  .then(invocation -> {
                      clock.waitUntil(AbortingIndexerLock.TIMEOUT_SECONDS * 1000 + 1);
                      return IndexStatsMBean.STATUS_RUNNING;
                  });
  
          try {
              lock.lock("async");
              fail();
          } catch (IllegalStateException ignore) {
  
          }
  
          verify(statsMBean).abortAndPause();
  
          verify(statsMBean, times(3)).getStatus();
      }
test_case.class_method_signature: AbortingIndexerLockTest.lockTimedout()
test_case.full_signature: @Test public void lockTimedout()
test_case.identifier: lockTimedout
test_case.invocations: then thenReturn thenReturn when getStatus waitUntil lock fail abortAndPause verify getStatus verify times
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void lockTimedout()
focal_class.declarator: TIMEOUT_SECONDS = 300
focal_class.modifier: public static final
focal_class.original_string: public static final int TIMEOUT_SECONDS = 300;
focal_class.type: int
focal_class.var_name: TIMEOUT_SECONDS
focal_class.declarator: log = LoggerFactory.getLogger(getClass())
focal_class.modifier: private final
focal_class.original_string: private final Logger log = LoggerFactory.getLogger(getClass());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: infoService
focal_class.modifier: private final
focal_class.original_string: private final AsyncIndexInfoService infoService;
focal_class.type: AsyncIndexInfoService
focal_class.var_name: infoService
focal_class.declarator: clock
focal_class.modifier: private final
focal_class.original_string: private final Clock clock;
focal_class.type: Clock
focal_class.var_name: clock
focal_class.file: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/AbortingIndexerLock.java
focal_class.identifier: AbortingIndexerLock
focal_class.interfaces: implements AsyncIndexerLock<SimpleToken>
focal_class.class_method_signature: AbortingIndexerLock.AbortingIndexerLock(AsyncIndexInfoService infoService)
focal_class.full_signature: public  AbortingIndexerLock(AsyncIndexInfoService infoService)
focal_class.identifier: AbortingIndexerLock
focal_class.modifiers: public
focal_class.parameters: (AsyncIndexInfoService infoService)
focal_class.signature:  AbortingIndexerLock(AsyncIndexInfoService infoService)
focal_class.class_method_signature: AbortingIndexerLock.AbortingIndexerLock(AsyncIndexInfoService infoService, Clock clock)
focal_class.full_signature: public  AbortingIndexerLock(AsyncIndexInfoService infoService, Clock clock)
focal_class.identifier: AbortingIndexerLock
focal_class.modifiers: public
focal_class.parameters: (AsyncIndexInfoService infoService, Clock clock)
focal_class.signature:  AbortingIndexerLock(AsyncIndexInfoService infoService, Clock clock)
focal_class.class_method_signature: AbortingIndexerLock.lock(String asyncIndexerLane)
focal_class.full_signature: @Override public SimpleToken lock(String asyncIndexerLane)
focal_class.identifier: lock
focal_class.modifiers: @Override public
focal_class.parameters: (String asyncIndexerLane)
focal_class.return: SimpleToken
focal_class.signature: SimpleToken lock(String asyncIndexerLane)
focal_class.class_method_signature: AbortingIndexerLock.unlock(SimpleToken token)
focal_class.full_signature: @Override public void unlock(SimpleToken token)
focal_class.identifier: unlock
focal_class.modifiers: @Override public
focal_class.parameters: (SimpleToken token)
focal_class.return: void
focal_class.signature: void unlock(SimpleToken token)
focal_class.class_method_signature: AbortingIndexerLock.getIndexStatsMBean(String asyncIndexerLane)
focal_class.full_signature: private IndexStatsMBean getIndexStatsMBean(String asyncIndexerLane)
focal_class.identifier: getIndexStatsMBean
focal_class.modifiers: private
focal_class.parameters: (String asyncIndexerLane)
focal_class.return: IndexStatsMBean
focal_class.signature: IndexStatsMBean getIndexStatsMBean(String asyncIndexerLane)
focal_class.class_method_signature: AbortingIndexerLock.retry(IndexStatsMBean mbean, int timeoutSeconds, int intervalBetweenTriesMsec)
focal_class.full_signature: private void retry(IndexStatsMBean mbean, int timeoutSeconds, int intervalBetweenTriesMsec)
focal_class.identifier: retry
focal_class.modifiers: private
focal_class.parameters: (IndexStatsMBean mbean, int timeoutSeconds, int intervalBetweenTriesMsec)
focal_class.return: void
focal_class.signature: void retry(IndexStatsMBean mbean, int timeoutSeconds, int intervalBetweenTriesMsec)
focal_method.body: @Override
      public SimpleToken lock(String asyncIndexerLane) {
          IndexStatsMBean mbean = getIndexStatsMBean(asyncIndexerLane);
  
          if (IndexStatsMBean.STATUS_RUNNING.equals(mbean.getStatus())){
              log.info("Aborting current indexing run of async indexer for lane [{}]", asyncIndexerLane);
          }
  
          mbean.abortAndPause();
          retry(mbean, TIMEOUT_SECONDS, 1000);
          log.info("Aborted and paused async indexer for lane [{}]", asyncIndexerLane);
          return new SimpleToken(asyncIndexerLane);
      }
focal_method.class_method_signature: AbortingIndexerLock.lock(String asyncIndexerLane)
focal_method.full_signature: @Override public SimpleToken lock(String asyncIndexerLane)
focal_method.identifier: lock
focal_method.invocations: getIndexStatsMBean equals getStatus info abortAndPause retry info
focal_method.modifiers: @Override public
focal_method.parameters: (String asyncIndexerLane)
focal_method.return: SimpleToken
focal_method.signature: SimpleToken lock(String asyncIndexerLane)