private void runWhenPermitted() { if (indexStats.isPaused()) { log.debug("[{}] Ignoring the run as indexing is paused", name); return; String err = String.format("Another copy of the index update is already running; skipping this update. " + "Time left for lease to expire %d s. Indexing can resume by %tT", leaseExpMsg, leaseEndTime); indexStats.failed(new Exception(err, newConcurrentUpdateException())); return; callback.initLease(); } catch (CommitFailedException e) { indexStats.failed(e); return; if (indexStats.didLastIndexingCycleFailed()) { indexStats.fixed(); indexStats.setReferenceCheckpoint(afterCheckpoint); indexStats.setProcessedCheckpoint(""); indexStats.releaseTempCheckpoint(afterCheckpoint); indexStats.failed(e);
private void maybeCleanUpCheckpoints() { // clean up every five minutes long currentMinutes = TimeUnit.MILLISECONDS.toMinutes( System.currentTimeMillis()); if (!indexStats.isFailing() && cleanupIntervalMinutes > -1 && lastCheckpointCleanUpTime + cleanupIntervalMinutes < currentMinutes) { try { cleanUpCheckpoints(); } catch (Throwable e) { log.warn("Checkpoint clean up failed", e); } lastCheckpointCleanUpTime = currentMinutes; } }
@Override public String abortAndPause() { //First pause to avoid any race pause(); //Set the forcedStop flag anyway. In resume this would be cleared forcedStopFlag.set(true); String msg = ""; //Abort if any indexing run is in progress if (runPermit.availablePermits() == 0){ msg = "Abort request placed for current run. "; } return msg + "Indexing is paused now. Invoke 'resume' to resume indexing"; }
private void runWhenPermitted() { if (indexStats.isPaused()) { log.debug("[{}] Ignoring the run as indexing is paused", name); return; String err = String.format("Another copy of the index update is already running; skipping this update. " + "Time left for lease to expire %d s. Indexing can resume by %tT", leaseExpMsg, leaseEndTime); indexStats.failed(new Exception(err, newConcurrentUpdateException())); return; callback.initLease(); } catch (CommitFailedException e) { indexStats.failed(e); return; if (indexStats.didLastIndexingCycleFailed()) { indexStats.fixed(); indexStats.setReferenceCheckpoint(afterCheckpoint); indexStats.setProcessedCheckpoint(""); indexStats.releaseTempCheckpoint(afterCheckpoint); indexStats.failed(e);
private void runWhenPermitted() { if (indexStats.isPaused()) { log.debug("[{}] Ignoring the run as indexing is paused", name); return; String err = String.format("Another copy of the index update is already running; skipping this update. " + "Time left for lease to expire %d s. Indexing can resume by %tT", leaseExpMsg, leaseEndTime); indexStats.failed(new Exception(err, newConcurrentUpdateException())); return; callback.initLease(); } catch (CommitFailedException e) { indexStats.failed(e); return; if (indexStats.didLastIndexingCycleFailed()) { indexStats.fixed(); indexStats.setReferenceCheckpoint(afterCheckpoint); indexStats.setProcessedCheckpoint(""); indexStats.releaseTempCheckpoint(afterCheckpoint); indexStats.failed(e);
log.info(msg, name, watch, indexStats.getUpdates(), indexUpdate.getIndexingStats()); } else { log.debug(msg, name, watch, indexStats.getUpdates(), indexUpdate.getIndexingStats());
log.info(msg, name, watch, indexStats.getUpdates(), indexUpdate.getIndexingStats()); } else { log.debug(msg, name, watch, indexStats.getUpdates(), indexUpdate.getIndexingStats());
log.info(msg, name, watch, indexStats.getUpdates(), indexUpdate.getIndexingStats()); } else { log.debug(msg, name, watch, indexStats.getUpdates(), indexUpdate.getIndexingStats());
assertTrue(async.getIndexStats().isFailing()); async.close();
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());
String since = stats.getFailingSince(); assertTrue(stats.isFailing()); assertEquals(1, stats.getConsecutiveFailedExecutions()); assertEquals(since, stats.getLatestErrorTime()); assertTrue(stats.isFailing()); assertEquals(2, stats.getConsecutiveFailedExecutions()); assertEquals(since, stats.getFailingSince()); assertNotEquals(since, stats.getLatestErrorTime()); stats.fixed(); assertFalse(stats.isFailing()); assertEquals(0, stats.getConsecutiveFailedExecutions()); assertEquals("", stats.getFailingSince());
assertEquals(3, stats.getNodesReadCount()); assertEquals(0, stats.getUpdates()); assertEquals(3, stats.getNodesReadCount()); assertEquals(1, stats.getUpdates());
@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")); }
private void maybeCleanUpCheckpoints() { // clean up every five minutes long currentMinutes = TimeUnit.MILLISECONDS.toMinutes( System.currentTimeMillis()); if (!indexStats.isFailing() && cleanupIntervalMinutes > -1 && lastCheckpointCleanUpTime + cleanupIntervalMinutes < currentMinutes) { try { cleanUpCheckpoints(); } catch (Throwable e) { log.warn("Checkpoint clean up failed", e); } lastCheckpointCleanUpTime = currentMinutes; } }
private void maybeCleanUpCheckpoints() { // clean up every five minutes long currentMinutes = TimeUnit.MILLISECONDS.toMinutes( System.currentTimeMillis()); if (!indexStats.isFailing() && cleanupIntervalMinutes > -1 && lastCheckpointCleanUpTime + cleanupIntervalMinutes < currentMinutes) { try { cleanUpCheckpoints(); } catch (Throwable e) { log.warn("Checkpoint clean up failed", e); } lastCheckpointCleanUpTime = currentMinutes; } }
boolean isDirty() { return indexStats.getUpdates() > 0; }
public boolean isFailing() { return indexStats.isFailing(); }
public boolean isFinished() { return indexStats.getStatus() == STATUS_DONE; }
public boolean isFailing() { return indexStats.isFailing(); }