Aliased analyzers cause index deletion / cleanup failure, closes #555.

This commit is contained in:
kimchy 2010-12-08 19:30:38 +02:00
parent f5a8c3881f
commit 34f3f3f79e
2 changed files with 23 additions and 8 deletions

View File

@ -160,7 +160,14 @@ public class AnalysisService extends AbstractIndexComponent implements Closeable
public void close() {
for (NamedAnalyzer analyzer : analyzers.values()) {
if (analyzer.scope() == AnalyzerScope.INDEX) {
analyzer.close();
try {
analyzer.close();
} catch (NullPointerException e) {
// because analyzers are aliased, they might be closed several times
// an NPE is thrown in this case, so ignore....
} catch (Exception e) {
logger.debug("failed to close analyzer " + analyzer);
}
}
}
}

View File

@ -134,7 +134,11 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
logger.debug("[{}] cleaning index (no shards allocated)", index);
}
// clean the index
indicesService.cleanIndex(index);
try {
indicesService.cleanIndex(index);
} catch (Exception e) {
logger.warn("failed to clean index (no shards of that index are allocated on this node)", e);
}
}
}
}
@ -145,12 +149,16 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
if (logger.isDebugEnabled()) {
logger.debug("[{}] deleting index", index);
}
indicesService.deleteIndex(index);
threadPool.execute(new Runnable() {
@Override public void run() {
nodeIndexDeletedAction.nodeIndexDeleted(index, event.state().nodes().localNodeId());
}
});
try {
indicesService.deleteIndex(index);
threadPool.execute(new Runnable() {
@Override public void run() {
nodeIndexDeletedAction.nodeIndexDeleted(index, event.state().nodes().localNodeId());
}
});
} catch (Exception e) {
logger.warn("failed to delete index", e);
}
}
}
}