Permalink
Browse files

add internal origin to delete by query

  • Loading branch information...
kimchy committed Sep 22, 2013
1 parent 0f17a4c commit e7e39936b854335b5a875bbecc3cbbdc28048bb3
@@ -92,7 +92,8 @@ protected ClusterBlockException checkRequestBlock(ClusterState state, ShardDelet
protected PrimaryResponse<ShardDeleteByQueryResponse, ShardDeleteByQueryRequest> shardOperationOnPrimary(ClusterState clusterState, PrimaryOperationRequest shardRequest) {
ShardDeleteByQueryRequest request = shardRequest.request;
IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId);
Engine.DeleteByQuery deleteByQuery = indexShard.prepareDeleteByQuery(request.querySource(), request.filteringAliases(), request.types());
Engine.DeleteByQuery deleteByQuery = indexShard.prepareDeleteByQuery(request.querySource(), request.filteringAliases(), request.types())
.origin(Engine.Operation.Origin.PRIMARY);
indexShard.deleteByQuery(deleteByQuery);
return new PrimaryResponse<ShardDeleteByQueryResponse, ShardDeleteByQueryRequest>(shardRequest.request, new ShardDeleteByQueryResponse(), null);
}
@@ -102,7 +103,8 @@ protected ClusterBlockException checkRequestBlock(ClusterState state, ShardDelet
protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) {
ShardDeleteByQueryRequest request = shardRequest.request;
IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.request.index()).shardSafe(shardRequest.shardId);
Engine.DeleteByQuery deleteByQuery = indexShard.prepareDeleteByQuery(request.querySource(), request.filteringAliases(), request.types());
Engine.DeleteByQuery deleteByQuery = indexShard.prepareDeleteByQuery(request.querySource(), request.filteringAliases(), request.types())
.origin(Engine.Operation.Origin.REPLICA);
indexShard.deleteByQuery(deleteByQuery);
}
@@ -748,6 +748,7 @@ public long endTime() {
private final Filter aliasFilter;
private final String[] types;
private final Filter parentFilter;
private Operation.Origin origin = Operation.Origin.PRIMARY;
private long startTime;
private long endTime;
@@ -789,6 +790,15 @@ public Filter parentFilter() {
return parentFilter;
}
public DeleteByQuery origin(Operation.Origin origin) {
this.origin = origin;
return this;
}
public Operation.Origin origin() {
return this.origin;
}
public DeleteByQuery startTime(long startTime) {
this.startTime = startTime;
return this;
@@ -691,7 +691,8 @@ public void performRecoveryOperation(Translog.Operation operation) throws Elasti
break;
case DELETE_BY_QUERY:
Translog.DeleteByQuery deleteByQuery = (Translog.DeleteByQuery) operation;
engine.delete(prepareDeleteByQuery(deleteByQuery.source(), deleteByQuery.filteringAliases(), deleteByQuery.types()));
engine.delete(prepareDeleteByQuery(deleteByQuery.source(), deleteByQuery.filteringAliases(), deleteByQuery.types())
.origin(Engine.Operation.Origin.RECOVERY));
break;
default:
throw new ElasticSearchIllegalStateException("No operation defined for [" + operation + "]");

0 comments on commit e7e3993

Please sign in to comment.