Add listeners to postCreate etc
This commit is contained in:
parent
38805f3cbd
commit
2fe2c7fef8
|
@ -43,12 +43,19 @@ public abstract class IndexingOperationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the indexing operation occurred.
|
* Called after create index operation occurred.
|
||||||
*/
|
*/
|
||||||
public void postCreate(Engine.Create create) {
|
public void postCreate(Engine.Create create) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after create index operation occurred with exception.
|
||||||
|
*/
|
||||||
|
public void postCreate(Engine.Create create, Throwable ex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before the indexing occurs.
|
* Called before the indexing occurs.
|
||||||
*/
|
*/
|
||||||
|
@ -103,4 +110,11 @@ public abstract class IndexingOperationListener {
|
||||||
public void postDelete(Engine.Delete delete) {
|
public void postDelete(Engine.Delete delete) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after the delete operation occurred with exception.
|
||||||
|
*/
|
||||||
|
public void postDelete(Engine.Delete delete, Throwable ex) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,11 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
totalStats.indexCurrent.inc();
|
totalStats.indexCurrent.inc();
|
||||||
typeStats(create.type()).indexCurrent.inc();
|
typeStats(create.type()).indexCurrent.inc();
|
||||||
for (IndexingOperationListener listener : listeners) {
|
for (IndexingOperationListener listener : listeners) {
|
||||||
create = listener.preCreate(create);
|
try {
|
||||||
|
create = listener.preCreate(create);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("preCreate listener [{}] failed", e, listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return create;
|
return create;
|
||||||
}
|
}
|
||||||
|
@ -124,19 +128,31 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
try {
|
try {
|
||||||
listener.postCreate(create);
|
listener.postCreate(create);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("post listener [{}] failed", e, listener);
|
logger.warn("postCreate listener [{}] failed", e, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postCreate(Engine.Create create, Throwable ex) {
|
public void postCreate(Engine.Create create, Throwable ex) {
|
||||||
|
for (IndexingOperationListener listener : listeners) {
|
||||||
|
try {
|
||||||
|
listener.postCreate(create, ex);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("postCreate listener [{}] failed", e, listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Engine.Index preIndex(Engine.Index index) {
|
public Engine.Index preIndex(Engine.Index index) {
|
||||||
totalStats.indexCurrent.inc();
|
totalStats.indexCurrent.inc();
|
||||||
typeStats(index.type()).indexCurrent.inc();
|
typeStats(index.type()).indexCurrent.inc();
|
||||||
for (IndexingOperationListener listener : listeners) {
|
for (IndexingOperationListener listener : listeners) {
|
||||||
index = listener.preIndex(index);
|
try {
|
||||||
|
listener.preIndex(index);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("preIndex listener [{}] failed", e, listener);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +162,7 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
try {
|
try {
|
||||||
listener.postIndexUnderLock(index);
|
listener.postIndexUnderLock(index);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("post listener [{}] failed", e, listener);
|
logger.warn("postIndexUnderLock listener [{}] failed", e, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +179,7 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
try {
|
try {
|
||||||
listener.postIndex(index);
|
listener.postIndex(index);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("post listener [{}] failed", e, listener);
|
logger.warn("postIndex listener [{}] failed", e, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +191,7 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
try {
|
try {
|
||||||
listener.postIndex(index, ex);
|
listener.postIndex(index, ex);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("post listener [{}] failed", e, listener);
|
logger.warn("postIndex listener [{}] failed", e, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +200,11 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
totalStats.deleteCurrent.inc();
|
totalStats.deleteCurrent.inc();
|
||||||
typeStats(delete.type()).deleteCurrent.inc();
|
typeStats(delete.type()).deleteCurrent.inc();
|
||||||
for (IndexingOperationListener listener : listeners) {
|
for (IndexingOperationListener listener : listeners) {
|
||||||
delete = listener.preDelete(delete);
|
try {
|
||||||
|
delete = listener.preDelete(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("preDelete listener [{}] failed", e, listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return delete;
|
return delete;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +214,7 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
try {
|
try {
|
||||||
listener.postDeleteUnderLock(delete);
|
listener.postDeleteUnderLock(delete);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("post listener [{}] failed", e, listener);
|
logger.warn("postDeleteUnderLock listener [{}] failed", e, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +230,7 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
try {
|
try {
|
||||||
listener.postDelete(delete);
|
listener.postDelete(delete);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("post listener [{}] failed", e, listener);
|
logger.warn("postDelete listener [{}] failed", e, listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,6 +238,13 @@ public class ShardIndexingService extends AbstractIndexShardComponent {
|
||||||
public void postDelete(Engine.Delete delete, Throwable ex) {
|
public void postDelete(Engine.Delete delete, Throwable ex) {
|
||||||
totalStats.deleteCurrent.dec();
|
totalStats.deleteCurrent.dec();
|
||||||
typeStats(delete.type()).deleteCurrent.dec();
|
typeStats(delete.type()).deleteCurrent.dec();
|
||||||
|
for (IndexingOperationListener listener : listeners) {
|
||||||
|
try {
|
||||||
|
listener.postDelete(delete, ex);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("postDelete listener [{}] failed", e, listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noopUpdate(String type) {
|
public void noopUpdate(String type) {
|
||||||
|
|
Loading…
Reference in New Issue