protected void unbindStatsMBeans(IndexStatsMBean mBean) { statsMBeans.remove(mBean.getName()); }
protected void unbindStatsMBeans(IndexStatsMBean mBean) { statsMBeans.remove(mBean.getName()); }
protected void unbindStatsMBeans(IndexStatsMBean mBean) { statsMBeans.remove(mBean.getName()); }
@Reference(name = "statsMBeans", policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE, policyOption = ReferencePolicyOption.GREEDY, service = IndexStatsMBean.class ) protected void bindStatsMBeans(IndexStatsMBean mBean) { statsMBeans.put(mBean.getName(), mBean); }
@Reference(name = "statsMBeans", policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE, policyOption = ReferencePolicyOption.GREEDY, service = IndexStatsMBean.class ) protected void bindStatsMBeans(IndexStatsMBean mBean) { statsMBeans.put(mBean.getName(), mBean); }
@Reference(name = "statsMBeans", policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE, policyOption = ReferencePolicyOption.GREEDY, service = IndexStatsMBean.class ) protected void bindStatsMBeans(IndexStatsMBean mBean) { statsMBeans.put(mBean.getName(), mBean); }
private void retry(IndexStatsMBean mbean, int timeoutSeconds, int intervalBetweenTriesMsec) { long timeout = clock.getTime() + timeoutSeconds * 1000L; while (clock.getTime() < timeout) { try { if (!IndexStatsMBean.STATUS_RUNNING.equals(mbean.getStatus())) { return; } } catch (Exception e) { throw new RuntimeException(e); } try { int delta = (int) (timeout - clock.getTime() / 1000); log.info("Async indexer for lane [{}] found to be running. Would wait for {} seconds " + "more for it to stop", mbean.getName(), delta); Thread.sleep(intervalBetweenTriesMsec); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } throw new IllegalStateException("RetryLoop failed, condition is false after " + timeoutSeconds + " seconds"); } }
private void retry(IndexStatsMBean mbean, int timeoutSeconds, int intervalBetweenTriesMsec) { long timeout = clock.getTime() + timeoutSeconds * 1000L; while (clock.getTime() < timeout) { try { if (!IndexStatsMBean.STATUS_RUNNING.equals(mbean.getStatus())) { return; } } catch (Exception e) { throw new RuntimeException(e); } try { int delta = (int) (timeout - clock.getTime() / 1000); log.info("Async indexer for lane [{}] found to be running. Would wait for {} seconds " + "more for it to stop", mbean.getName(), delta); Thread.sleep(intervalBetweenTriesMsec); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } throw new IllegalStateException("RetryLoop failed, condition is false after " + timeoutSeconds + " seconds"); } }
private void retry(IndexStatsMBean mbean, int timeoutSeconds, int intervalBetweenTriesMsec) { long timeout = clock.getTime() + timeoutSeconds * 1000L; while (clock.getTime() < timeout) { try { if (!IndexStatsMBean.STATUS_RUNNING.equals(mbean.getStatus())) { return; } } catch (Exception e) { throw new RuntimeException(e); } try { int delta = (int) (timeout - clock.getTime() / 1000); log.info("Async indexer for lane [{}] found to be running. Would wait for {} seconds " + "more for it to stop", mbean.getName(), delta); Thread.sleep(intervalBetweenTriesMsec); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; } } throw new IllegalStateException("RetryLoop failed, condition is false after " + timeoutSeconds + " seconds"); } }
LOG.warn("Exception during getting status for {}. Ignoring this indexer lane", bean.getName(), e); return false; LOG.info("Lane {} has moved - oldExecCnt {}, newExecCnt {}", indexLaneBean.getName(), oldExecCnt, newExecCnt); } else if (clock.getTime() - start > TimeUnit.MINUTES.toMillis(2)) { LOG.warn("Timed out while waiting for running index lane executions"); break; } else { LOG.info("Lane {} still has execution count {}. Waiting....", indexLaneBean.getName(), newExecCnt);
LOG.warn("Exception during getting status for {}. Ignoring this indexer lane", bean.getName(), e); return false; LOG.info("Lane {} has moved - oldExecCnt {}, newExecCnt {}", indexLaneBean.getName(), oldExecCnt, newExecCnt); } else if (clock.getTime() - start > TimeUnit.MINUTES.toMillis(2)) { LOG.warn("Timed out while waiting for running index lane executions"); break; } else { LOG.info("Lane {} still has execution count {}. Waiting....", indexLaneBean.getName(), newExecCnt);
static AsyncIndexInfoService getAsyncIndexInfoService(List<IndexMBeanInfoSupplier> infoSuppliers) { AsyncIndexInfoService service = mock(AsyncIndexInfoService.class); List<String> asyncLanes = Lists.newArrayList(); for (IndexMBeanInfoSupplier info : infoSuppliers) { String lane = info.getName(); IndexStatsMBean bean = mock(IndexStatsMBean.class); when(bean.getName()).thenReturn(lane); when(bean.getStatus()).then(mockObj -> info.getStatus()); when(bean.getTotalExecutionCount()).then(mockObj -> info.getExecCnt()); when(service.getInfo(lane)).then(mockObj -> new AsyncIndexInfo( lane, 1324L, 4567L, STATUS_RUNNING.equals(info.getStatus()), bean )); asyncLanes.add(lane); } when(service.getAsyncLanes()).thenReturn(asyncLanes); return service; }
@Test public void asyncReg() throws Exception{ injectDefaultServices(); Map<String,Object> config = ImmutableMap.<String, Object>of( "asyncConfigs", new String[] {"async:5"} ); MockOsgi.activate(service, context.bundleContext(), config); assertNotNull(context.getService(Runnable.class)); assertEquals(TimeUnit.MINUTES.toMillis(15), getIndexUpdate("async").getLeaseTimeOut()); AsyncIndexUpdate indexUpdate = getIndexUpdate("async"); IndexStatsMBean mbean = context.getService(IndexStatsMBean.class); assertNotNull(mbean); assertEquals("async", mbean.getName()); MockOsgi.deactivate(service, context.bundleContext()); assertNull(context.getService(Runnable.class)); assertTrue(indexUpdate.isClosed()); }