Java Code Examples for org.elasticsearch.index.engine.Engine#DeleteResult
The following examples show how to use
org.elasticsearch.index.engine.Engine#DeleteResult .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebSocketIndexListener.java From es-change-feed-plugin with Apache License 2.0 | 5 votes |
@Override public void postDelete(ShardId shardId, Engine.Delete delete, Engine.DeleteResult result) { ChangeEvent change=new ChangeEvent( shardId.getIndex().getName(), delete.type(), delete.id(), new DateTime(), ChangeEvent.Operation.DELETE, result.getVersion(), null ); addChange(change); }
Example 2
Source File: IndexingOperationListener.java From crate with Apache License 2.0 | 5 votes |
@Override public void postDelete(ShardId shardId, Engine.Delete delete, Engine.DeleteResult result) { assert delete != null; for (IndexingOperationListener listener : listeners) { try { listener.postDelete(shardId, delete, result); } catch (Exception e) { logger.warn(() -> new ParameterizedMessage("postDelete listener [{}] failed", listener), e); } } }
Example 3
Source File: IndexShard.java From crate with Apache License 2.0 | 5 votes |
public Engine.DeleteResult applyDeleteOperationOnPrimary(long version, String type, String id, VersionType versionType, long ifSeqNo, long ifPrimaryTerm) throws IOException { return applyDeleteOperation(getEngine(), UNASSIGNED_SEQ_NO, operationPrimaryTerm, version, type, id, versionType, ifSeqNo, ifPrimaryTerm, Engine.Operation.Origin.PRIMARY); }
Example 4
Source File: IndexShard.java From crate with Apache License 2.0 | 5 votes |
public Engine.DeleteResult applyDeleteOperationOnReplica(long seqNo, long version, String type, String id) throws IOException { return applyDeleteOperation( getEngine(), seqNo, operationPrimaryTerm, version, type, id, null, UNASSIGNED_SEQ_NO, 0, Engine.Operation.Origin.REPLICA); }
Example 5
Source File: IndexShard.java From crate with Apache License 2.0 | 5 votes |
private Engine.DeleteResult applyDeleteOperation(Engine engine, long seqNo, long opPrimaryTerm, long version, String type, String id, @Nullable VersionType versionType, long ifSeqNo, long ifPrimaryTerm, Engine.Operation.Origin origin) throws IOException { assert opPrimaryTerm <= this.operationPrimaryTerm : "op term [ " + opPrimaryTerm + " ] > shard term [" + this.operationPrimaryTerm + "]"; ensureWriteAllowed(origin); // When there is a single type, the unique identifier is only composed of the _id, // so there is no way to differentiate foo#1 from bar#1. This is especially an issue // if a user first deletes foo#1 and then indexes bar#1: since we do not encode the // _type in the uid it might look like we are reindexing the same document, which // would fail if bar#1 is indexed with a lower version than foo#1 was deleted with. // In order to work around this issue, we make deletions create types. This way, we // fail if index and delete operations do not use the same type. final Term uid = extractUidForDelete(type, id); final Engine.Delete delete = prepareDelete( type, id, uid, seqNo, opPrimaryTerm, version, versionType, origin, ifSeqNo, ifPrimaryTerm ); return delete(engine, delete); }
Example 6
Source File: TransportShardDeleteAction.java From crate with Apache License 2.0 | 5 votes |
@Override protected WriteReplicaResult<ShardDeleteRequest> processRequestItemsOnReplica(IndexShard indexShard, ShardDeleteRequest request) throws IOException { Translog.Location translogLocation = null; for (ShardDeleteRequest.Item item : request.items()) { int location = item.location(); if (request.skipFromLocation() == location) { // skipping this and all next items, the primary did not processed them (mostly due to a kill request) break; } // Only execute delete operation on replica if the sequence number was applied from primary. // If that's not the case, the delete on primary didn't succeed. Note that we still need to // process the other items in case of a bulk request. if (item.seqNo() != SequenceNumbers.UNASSIGNED_SEQ_NO) { Engine.DeleteResult deleteResult = indexShard.applyDeleteOperationOnReplica(item.seqNo(), item.version(), Constants.DEFAULT_MAPPING_TYPE, item.id()); translogLocation = deleteResult.getTranslogLocation(); if (logger.isTraceEnabled()) { logger.trace("shardId={} REPLICA: successfully deleted id={}", request.shardId(), item.id()); } } } return new WriteReplicaResult<>(request, translogLocation, null, indexShard, logger); }
Example 7
Source File: TransportShardDeleteAction.java From crate with Apache License 2.0 | 5 votes |
private Engine.DeleteResult shardDeleteOperationOnPrimary(ShardDeleteRequest.Item item, IndexShard indexShard) throws IOException { Engine.DeleteResult deleteResult = indexShard.applyDeleteOperationOnPrimary( item.version(), Constants.DEFAULT_MAPPING_TYPE, item.id(), VersionType.INTERNAL, item.seqNo(), item.primaryTerm()); // set version and sequence number for replica item.version(deleteResult.getVersion()); item.seqNo(deleteResult.getSeqNo()); return deleteResult; }
Example 8
Source File: IndexingMemoryController.java From crate with Apache License 2.0 | 4 votes |
@Override public void postDelete(ShardId shardId, Engine.Delete delete, Engine.DeleteResult result) { recordOperationBytes(delete, result); }
Example 9
Source File: Translog.java From crate with Apache License 2.0 | 4 votes |
public Delete(Engine.Delete delete, Engine.DeleteResult deleteResult) { this(delete.type(), delete.id(), delete.uid(), deleteResult.getSeqNo(), delete.primaryTerm(), deleteResult.getVersion()); }
Example 10
Source File: IndexingOperationListener.java From crate with Apache License 2.0 | 2 votes |
/** * Called after the delete operation occurred. Note that this is * also called when deleting a document did not succeed due to document * related failures. See {@link #postDelete(ShardId, Engine.Delete, Exception)} * for engine level failures */ default void postDelete(ShardId shardId, Engine.Delete delete, Engine.DeleteResult result) { }