public void registerAsyncIndexer(AsyncIndexUpdate task, long delayInSeconds) { task.setIndexMBeanRegistration(this); Map<String, Object> config = ImmutableMap.<String, Object>of( AsyncIndexUpdate.PROP_ASYNC_NAME, task.getName(), "scheduler.name", AsyncIndexUpdate.class.getName() + "-" + task.getName() ); regs.add(scheduleWithFixedDelay(whiteboard, task, config, delayInSeconds, RUN_ON_LEADER, true)); regs.add(registerMBean(whiteboard, IndexStatsMBean.class, task.getIndexStats(), IndexStatsMBean.TYPE, task.getName())); }
public void registerAsyncIndexer(AsyncIndexUpdate task, long delayInSeconds) { task.setIndexMBeanRegistration(this); Map<String, Object> config = ImmutableMap.<String, Object>of( AsyncIndexUpdate.PROP_ASYNC_NAME, task.getName(), "scheduler.name", AsyncIndexUpdate.class.getName() + "-" + task.getName() ); regs.add(scheduleWithFixedDelay(whiteboard, task, config, delayInSeconds, RUN_ON_LEADER, true)); regs.add(registerMBean(whiteboard, IndexStatsMBean.class, task.getIndexStats(), IndexStatsMBean.TYPE, task.getName())); }
public void registerAsyncIndexer(AsyncIndexUpdate task, long delayInSeconds) { task.setIndexMBeanRegistration(this); Map<String, Object> config = ImmutableMap.<String, Object>of( AsyncIndexUpdate.PROP_ASYNC_NAME, task.getName(), "scheduler.name", AsyncIndexUpdate.class.getName() + "-" + task.getName() ); regs.add(scheduleWithFixedDelay(whiteboard, task, config, delayInSeconds, RUN_ON_LEADER, true)); regs.add(registerMBean(whiteboard, IndexStatsMBean.class, task.getIndexStats(), IndexStatsMBean.TYPE, task.getName())); }
@Override public Boolean call() throws Exception { return IndexStatsMBean.STATUS_INTERRUPTED.equals(async.getIndexStats().getStatus()); } });
private void registerAsyncReindexSupport(Whiteboard whiteboard) { // async reindex String name = IndexConstants.ASYNC_REINDEX_VALUE; AsyncIndexUpdate task = new AsyncIndexUpdate(name, nodeStore, indexEditorProvider, statisticsProvider, true); PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex(task, executor); final Registration reg = new CompositeRegistration( registerMBean(whiteboard, PropertyIndexAsyncReindexMBean.class, asyncPI, PropertyIndexAsyncReindexMBean.TYPE, "async"), registerMBean(whiteboard, IndexStatsMBean.class, task.getIndexStats(), IndexStatsMBean.TYPE, name)); closer.register(new Closeable() { @Override public void close() throws IOException { reg.unregister(); } }); }
private void registerAsyncReindexSupport(Whiteboard whiteboard) { // async reindex String name = IndexConstants.ASYNC_REINDEX_VALUE; AsyncIndexUpdate task = new AsyncIndexUpdate(name, nodeStore, indexEditorProvider, statisticsProvider, true); PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex(task, executor); final Registration reg = new CompositeRegistration( registerMBean(whiteboard, PropertyIndexAsyncReindexMBean.class, asyncPI, PropertyIndexAsyncReindexMBean.TYPE, "async"), registerMBean(whiteboard, IndexStatsMBean.class, task.getIndexStats(), IndexStatsMBean.TYPE, name)); closer.register(new Closeable() { @Override public void close() throws IOException { reg.unregister(); } }); }
private void registerAsyncReindexSupport(Whiteboard whiteboard) { // async reindex String name = IndexConstants.ASYNC_REINDEX_VALUE; AsyncIndexUpdate task = new AsyncIndexUpdate(name, nodeStore, indexEditorProvider, statisticsProvider, true); PropertyIndexAsyncReindex asyncPI = new PropertyIndexAsyncReindex(task, executor); final Registration reg = new CompositeRegistration( registerMBean(whiteboard, PropertyIndexAsyncReindexMBean.class, asyncPI, PropertyIndexAsyncReindexMBean.TYPE, "async"), registerMBean(whiteboard, IndexStatsMBean.class, task.getIndexStats(), IndexStatsMBean.TYPE, name)); closer.register(new Closeable() { @Override public void close() throws IOException { reg.unregister(); } }); }
private void assertRunKo(AsyncIndexUpdate a) { assertRun(a, true); assertConcurrentUpdate(a.getIndexStats()); }
@Test public void names() throws Exception{ AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider); async.run(); AsyncIndexUpdate async2 = new AsyncIndexUpdate("foo-async", store, provider); async2.run(); Set<String> names = ImmutableSet.copyOf(service.getAsyncLanes()); assertThat(names, containsInAnyOrder("async", "foo-async")); service.bindStatsMBeans(async.getIndexStats()); service.bindStatsMBeans(async2.getIndexStats()); }
@Test public void executionCountUpdatesOnRunWithoutAnyChangeInRepo() throws Exception { AsyncIndexUpdate async = new AsyncIndexUpdate("async", new MemoryNodeStore(), new PropertyIndexEditorProvider(), statsProvider, false); long execCnt1 = async.getIndexStats().getTotalExecutionCount(); runOneCycle(async); long execCnt2 = async.getIndexStats().getTotalExecutionCount(); runOneCycle(async); long execCnt3 = async.getIndexStats().getTotalExecutionCount(); assertNotEquals("execCnt1 " + execCnt1 + " and execCnt2 " + execCnt2 + " are same", execCnt1, execCnt2); assertNotEquals("execCnt2 " + execCnt2 + " and execCnt3 " + execCnt3 + " are same", execCnt2, execCnt3); }
assertEquals(IndexStatsMBean.STATUS_DONE, async.getIndexStats().getStatus()); assertEquals(IndexStatsMBean.STATUS_RUNNING, async.getIndexStats().getStatus()); assertThat(async.getIndexStats().abortAndPause(), containsString("Abort request placed")); assertTrue(async.getIndexStats().isPaused()); async.getIndexStats().resume(); assertEquals(IndexStatsMBean.STATUS_DONE, async.getIndexStats().getStatus()); assertFalse(async.isClosed());
@Test public void info() throws Exception{ AsyncIndexUpdate async = new AsyncIndexUpdate("foo-async", store, provider); async.run(); Set<String> names = ImmutableSet.copyOf(service.getAsyncLanes()); assertThat(names, containsInAnyOrder("foo-async")); service.bindStatsMBeans(async.getIndexStats()); AsyncIndexInfo info = service.getInfo("foo-async"); assertNotNull(info); assertEquals("foo-async", info.getName()); assertNotNull(info.getStatsMBean()); assertTrue(info.getLastIndexedTo() > -1); assertFalse(info.isRunning()); assertEquals(-1, info.getLeaseExpiryTime()); System.out.println(info); service.unbindStatsMBeans(async.getIndexStats()); AsyncIndexInfo info2 = service.getInfo("foo-async"); assertNull(info2.getStatsMBean()); }
assertEquals(1, async.getIndexStats().getExecutionStats().getExecutionCounter().getCount()); assertEquals(2, async.getIndexStats().getExecutionStats().getExecutionCounter().getCount()); long indexedNodeCount = async.getIndexStats().getExecutionStats().getIndexedNodeCount().getCount(); assertEquals(indexedNodeCount, async.getIndexStats().getExecutionStats().getIndexedNodeCount().getCount()); assertEquals(4, async.getIndexStats().getExecutionStats().getExecutionCounter().getCount()); assertEquals(0, lastExecutionStats(async.getIndexStats().getExecutionCount()));
@Test public void testAsyncPause() throws Exception { NodeStore store = new MemoryNodeStore(); IndexEditorProvider provider = new PropertyIndexEditorProvider(); NodeBuilder builder = store.getRoot().builder(); createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null) .setProperty(ASYNC_PROPERTY_NAME, "async"); builder.child("testRoot").setProperty("foo", "abc"); // merge it back in store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); AsyncIndexUpdate async = new AsyncIndexUpdate("async", store, provider); async.getIndexStats().pause(); async.run(); assertFalse(store.getRoot().getChildNode(INDEX_DEFINITIONS_NAME) .getChildNode("rootIndex") .hasChildNode(INDEX_CONTENT_NODE_NAME)); async.getIndexStats().resume(); async.run(); NodeState root = store.getRoot(); // first check that the index content nodes exist checkPathExists(root, INDEX_DEFINITIONS_NAME, "rootIndex", INDEX_CONTENT_NODE_NAME); assertFalse(root.getChildNode(INDEX_DEFINITIONS_NAME).hasChildNode( ":conflict")); PropertyIndexLookup lookup = new PropertyIndexLookup(root); assertEquals(ImmutableSet.of("testRoot"), find(lookup, "foo", "abc")); }
assertTrue(async.getIndexStats().isFailing()); async.close();
assertTrue(async.getIndexStats().isFailing()); assertTrue(async.getIndexStats().isFailing()); assertEquals(IndexStatsMBean.STATUS_FAILING, async.getIndexStats().getStatus()); assertTrue(async.getIndexStats().isFailing());
AsyncIndexStats stats = async.getIndexStats(); assertEquals(3, stats.getNodesReadCount()); assertEquals(0, stats.getUpdates()); stats = async.getIndexStats(); assertEquals(3, stats.getNodesReadCount()); assertEquals(1, stats.getUpdates());
AsyncIndexStats stats = async.getIndexStats(); String since = stats.getFailingSince(); assertTrue(stats.isFailing());