diff --git a/core/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java b/core/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java index 8b95e0f132b..ba968172c98 100644 --- a/core/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java +++ b/core/src/main/java/org/elasticsearch/index/indexing/IndexingOperationListener.java @@ -73,6 +73,13 @@ public abstract class IndexingOperationListener { } + /** + * Called after the indexing operation occurred with exception. + */ + public void postIndex(Engine.Index index, Throwable ex) { + + } + /** * Called before the delete occurs. */ diff --git a/core/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java b/core/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java index 2109eafaaed..303c338184e 100644 --- a/core/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java +++ b/core/src/main/java/org/elasticsearch/index/indexing/ShardIndexingService.java @@ -171,6 +171,13 @@ public class ShardIndexingService extends AbstractIndexShardComponent { public void postIndex(Engine.Index index, Throwable ex) { totalStats.indexCurrent.dec(); typeStats(index.type()).indexCurrent.dec(); + for (IndexingOperationListener listener : listeners) { + try { + listener.postIndex(index, ex); + } catch (Exception e) { + logger.warn("post listener [{}] failed", e, listener); + } + } } public Engine.Delete preDelete(Engine.Delete delete) {