public boolean isFailing(String asyncName) { return !getFailingIndexData(asyncName).isEmpty(); }
public void fixed() { if (corruptIndexHandler.isFailing(name)){ log.info("[{}] Index update no longer fails but some corrupt indexes have been skipped {}", name, corruptIndexHandler.getCorruptIndexData(name).keySet()); } else { log.info("[{}] Index update no longer fails", name); } failing = false; failingSince = ""; consecutiveFailures = 0; latestErrorWarn = 0; latestError = null; latestErrorTime = ""; }
private TrackingCorruptIndexHandler createCorruptIndexHandler(Configuration config) { long failingIndexTimeoutSeconds = config.failingIndexTimeoutSeconds(); long errorWarnIntervalSeconds = config.errorWarnIntervalSeconds(); TrackingCorruptIndexHandler corruptIndexHandler = new TrackingCorruptIndexHandler(); corruptIndexHandler.setCorruptInterval(failingIndexTimeoutSeconds, TimeUnit.SECONDS); corruptIndexHandler.setErrorWarnInterval(errorWarnIntervalSeconds, TimeUnit.SECONDS); corruptIndexHandler.setMeterStats(statisticsProvider.getMeter(TrackingCorruptIndexHandler.CORRUPT_INDEX_METER_NAME, StatsOptions.METRICS_ONLY)); if (failingIndexTimeoutSeconds <= 0){ log.info("[failingIndexTimeoutSeconds] is set to {}. Auto corrupt index isolation handling is disabled, warning log would be " + "logged every {} s", failingIndexTimeoutSeconds, errorWarnIntervalSeconds); } else { log.info("Auto corrupt index isolation handling is enabled. Any async index which fails for {}s would " + "be marked as corrupted and would be skipped from further indexing. A warning log would be " + "logged every {} s", failingIndexTimeoutSeconds, errorWarnIntervalSeconds); } return corruptIndexHandler; }
private TrackingCorruptIndexHandler createCorruptIndexHandler(Configuration config) { long failingIndexTimeoutSeconds = config.failingIndexTimeoutSeconds(); long errorWarnIntervalSeconds = config.errorWarnIntervalSeconds(); TrackingCorruptIndexHandler corruptIndexHandler = new TrackingCorruptIndexHandler(); corruptIndexHandler.setCorruptInterval(failingIndexTimeoutSeconds, TimeUnit.SECONDS); corruptIndexHandler.setErrorWarnInterval(errorWarnIntervalSeconds, TimeUnit.SECONDS); if (failingIndexTimeoutSeconds <= 0){ log.info("[failingIndexTimeoutSeconds] is set to {}. Auto corrupt index isolation handling is disabled, warning log would be " + "logged every {} s", failingIndexTimeoutSeconds, errorWarnIntervalSeconds); } else { log.info("Auto corrupt index isolation handling is enabled. Any async index which fails for {}s would " + "be marked as corrupted and would be skipped from further indexing. A warning log would be " + "logged every {} s", failingIndexTimeoutSeconds, errorWarnIntervalSeconds); } return corruptIndexHandler; }
@Test public void disbaled() throws Exception{ handler.setClock(clock); handler.indexUpdateFailed("async", "/oak:index/foo", new Exception()); clock.waitUntil(clock.getTime() + handler.getCorruptIntervalMillis() + 1); assertTrue(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); handler.setCorruptInterval(0, TimeUnit.SECONDS); //With timeout set to zero no corrupt index should be reported assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); }
@Test public void basics() throws Exception{ handler.setClock(clock); handler.indexUpdateFailed("async", "/oak:index/foo", new Exception()); //Index would not be considered corrupt until timeout assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); clock.waitUntil(clock.getTime() + handler.getCorruptIntervalMillis() + 1); assertTrue(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); //Should only be visible for "async" assertFalse(handler.getCorruptIndexData("async-fulltext").containsKey("/oak:index/foo")); handler.markWorkingIndexes(Collections.singleton("/oak:index/foo")); assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); }
async.getCorruptIndexHandler().setClock(clock); async.run(); assertTrue(async.getIndexStats().isFailing()); assertTrue(async.getCorruptIndexHandler().getFailingIndexData("async").containsKey("/oak:index/barIndex")); assertFalse(async.getCorruptIndexHandler().getCorruptIndexData("async").containsKey("/oak:index/barIndex")); CorruptIndexInfo barIndexInfo = async.getCorruptIndexHandler().getFailingIndexData("async").get("/oak:index/barIndex"); assertFalse(async.getCorruptIndexHandler().getFailingIndexData("async").containsKey("/oak:index/fooIndex")); clock.waitUntil(clock.getTime() + async.getCorruptIndexHandler().getCorruptIntervalMillis() + 1); assertTrue(async.getCorruptIndexHandler().getCorruptIndexData("async").containsKey("/oak:index/barIndex")); assertFalse(async.getCorruptIndexHandler().getFailingIndexData("async").containsKey("/oak:index/barIndex"));
private void markFailingIndexesAsCorrupt(NodeBuilder builder) { for (Map.Entry<String, CorruptIndexInfo> index : corruptIndexHandler.getCorruptIndexData(name).entrySet()){ NodeBuilder indexBuilder = childBuilder(builder, index.getKey()); CorruptIndexInfo info = index.getValue(); if (!indexBuilder.hasProperty(IndexConstants.CORRUPT_PROPERTY_NAME)){ String corruptSince = ISO8601.format(info.getCorruptSinceAsCal()); indexBuilder.setProperty( PropertyStates.createProperty(IndexConstants.CORRUPT_PROPERTY_NAME, corruptSince, Type.DATE)); log.info("Marking [{}] as corrupt. The index is failing {}", info.getPath(), info.getStats()); } else { log.debug("Failing index at [{}] is already marked as corrupt. The index is failing {}", info.getPath(), info.getStats()); } } }
corruptIndexHandler.markWorkingIndexes(indexUpdate.getUpdatedIndexPaths()); } finally { if (indexUpdate != null) {
@Override public void indexUpdateFailed(String async, String indexPath, Exception e) { getOrCreateInfo(async, indexPath).addFailure(e); }
public boolean isFailing() { return failing || corruptIndexHandler.isFailing(name); }
@Override public TabularData getFailingIndexStats() { return corruptIndexHandler.getFailingIndexStats(name); } }
private void markFailingIndexesAsCorrupt(NodeBuilder builder) { for (Map.Entry<String, CorruptIndexInfo> index : corruptIndexHandler.getCorruptIndexData(name).entrySet()){ NodeBuilder indexBuilder = childBuilder(builder, index.getKey()); CorruptIndexInfo info = index.getValue(); if (!indexBuilder.hasProperty(IndexConstants.CORRUPT_PROPERTY_NAME)){ String corruptSince = ISO8601.format(info.getCorruptSinceAsCal()); indexBuilder.setProperty( PropertyStates.createProperty(IndexConstants.CORRUPT_PROPERTY_NAME, corruptSince, Type.DATE)); log.info("Marking [{}] as corrupt. The index is failing {}", info.getPath(), info.getStats()); } else { log.debug("Failing index at [{}] is already marked as corrupt. The index is failing {}", info.getPath(), info.getStats()); } } }
corruptIndexHandler.markWorkingIndexes(indexUpdate.getUpdatedIndexPaths()); } finally { if (indexUpdate != null) {
@Override public boolean skippingCorruptIndex(String async, String indexPath, Calendar corruptSince) { CorruptIndexInfo info = getOrCreateInfo(async, indexPath); if (info.skippedIndexing(checkNotNull(corruptSince))) { log.warn("Ignoring corrupt index [{}] which has been marked as corrupt [{}]. This index " + "MUST be reindexed for indexing to work properly", indexPath, info.getStats()); return true; } return false; }
public boolean isFailing() { return failing || corruptIndexHandler.isFailing(name); }
@Override public TabularData getFailingIndexStats() { return corruptIndexHandler.getFailingIndexStats(name); } }
private TrackingCorruptIndexHandler createCorruptIndexHandler(Configuration config) { long failingIndexTimeoutSeconds = config.failingIndexTimeoutSeconds(); long errorWarnIntervalSeconds = config.errorWarnIntervalSeconds(); TrackingCorruptIndexHandler corruptIndexHandler = new TrackingCorruptIndexHandler(); corruptIndexHandler.setCorruptInterval(failingIndexTimeoutSeconds, TimeUnit.SECONDS); corruptIndexHandler.setErrorWarnInterval(errorWarnIntervalSeconds, TimeUnit.SECONDS); corruptIndexHandler.setMeterStats(statisticsProvider.getMeter("corrupt-index", StatsOptions.METRICS_ONLY)); if (failingIndexTimeoutSeconds <= 0){ log.info("[failingIndexTimeoutSeconds] is set to {}. Auto corrupt index isolation handling is disabled, warning log would be " + "logged every {} s", failingIndexTimeoutSeconds, errorWarnIntervalSeconds); } else { log.info("Auto corrupt index isolation handling is enabled. Any async index which fails for {}s would " + "be marked as corrupted and would be skipped from further indexing. A warning log would be " + "logged every {} s", failingIndexTimeoutSeconds, errorWarnIntervalSeconds); } return corruptIndexHandler; }
public boolean isFailing(String asyncName) { return !getFailingIndexData(asyncName).isEmpty(); }
public void fixed() { if (corruptIndexHandler.isFailing(name)){ log.info("[{}] Index update no longer fails but some corrupt indexes have been skipped {}", name, corruptIndexHandler.getCorruptIndexData(name).keySet()); } else { log.info("[{}] Index update no longer fails", name); } failing = false; failingSince = ""; consecutiveFailures = 0; latestErrorWarn = 0; latestError = null; latestErrorTime = ""; }