Java Code Examples for org.elasticsearch.index.engine.Engine#Delete

The following examples show how to use org.elasticsearch.index.engine.Engine#Delete . 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: IndexingOperationListener.java    From crate with Apache License 2.0 5 votes vote down vote up
@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 2
Source File: WebSocketIndexListener.java    From es-change-feed-plugin with Apache License 2.0 5 votes vote down vote up
@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 3
Source File: IndexingOperationListener.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void postDelete(ShardId shardId, Engine.Delete delete, Exception ex) {
    assert delete != null && ex != null;
    for (IndexingOperationListener listener : listeners) {
        try {
            listener.postDelete(shardId, delete, ex);
        } catch (Exception inner) {
            inner.addSuppressed(ex);
            logger.warn(() -> new ParameterizedMessage("postDelete listener [{}] failed", listener), inner);
        }
    }
}
 
Example 4
Source File: IndexShard.java    From crate with Apache License 2.0 5 votes vote down vote up
private Engine.Delete prepareDelete(String type,
                                    String id,
                                    Term uid,
                                    long seqNo,
                                    long primaryTerm,
                                    long version,
                                    VersionType versionType,
                                    Engine.Operation.Origin origin,
                                    long ifSeqNo,
                                    long ifPrimaryTerm) {
    long startTime = System.nanoTime();
    return new Engine.Delete(type, id, uid, seqNo, primaryTerm, version, versionType, origin, startTime,
                             ifSeqNo, ifPrimaryTerm);
}
 
Example 5
Source File: ShardIndexingService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public void postDelete(Engine.Delete delete, Throwable ex) {
    totalStats.deleteCurrent.dec();
    typeStats(delete.type()).deleteCurrent.dec();
    for (IndexingOperationListener listener : listeners) {
        try {
            listener. postDelete(delete, ex);
        } catch (Throwable t) {
            logger.warn("postDelete listener [{}] failed", t, listener);
        }
    }
}
 
Example 6
Source File: ShardIndexingService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public void postDelete(Engine.Delete delete) {
    long took = delete.endTime() - delete.startTime();
    totalStats.deleteMetric.inc(took);
    totalStats.deleteCurrent.dec();
    StatsHolder typeStats = typeStats(delete.type());
    typeStats.deleteMetric.inc(took);
    typeStats.deleteCurrent.dec();
    for (IndexingOperationListener listener : listeners) {
        try {
            listener.postDelete(delete);
        } catch (Exception e) {
            logger.warn("postDelete listener [{}] failed", e, listener);
        }
    }
}
 
Example 7
Source File: ShardIndexingService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public void postDeleteUnderLock(Engine.Delete delete) {
    for (IndexingOperationListener listener : listeners) {
        try {
            listener.postDeleteUnderLock(delete);
        } catch (Exception e) {
            logger.warn("postDeleteUnderLock listener [{}] failed", e, listener);
        }
    }
}
 
Example 8
Source File: ShardIndexingService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public Engine.Delete preDelete(Engine.Delete delete) {
    totalStats.deleteCurrent.inc();
    typeStats(delete.type()).deleteCurrent.inc();
    for (IndexingOperationListener listener : listeners) {
        delete = listener.preDelete(delete);
    }
    return delete;
}
 
Example 9
Source File: IndexingOperationListener.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Called before the delete occurs.
 */
public Engine.Delete preDelete(Engine.Delete delete) {
    return delete;
}
 
Example 10
Source File: IndexShard.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public Engine.Delete prepareDeleteOnReplica(String type, String id, long version, VersionType versionType) {
    final DocumentMapper documentMapper = docMapper(type).getDocumentMapper();
    return prepareDelete(type, id, documentMapper.uidMapper().term(Uid.createUid(type, id)), version, versionType, Engine.Operation
            .Origin.REPLICA);
}
 
Example 11
Source File: IndexShard.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
static Engine.Delete prepareDelete(String type, String id, Term uid, long version, VersionType versionType, Engine.Operation.Origin
        origin) {
    long startTime = System.nanoTime();
    return new Engine.Delete(type, id, uid, version, versionType, origin, startTime, false);
}
 
Example 12
Source File: Translog.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public Delete(Engine.Delete delete) {
    this(delete.uid());
    this.version = delete.version();
    this.versionType = delete.versionType();
}
 
Example 13
Source File: TransportDeleteAction.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public static Engine.Delete executeDeleteRequestOnReplica(DeleteRequest request, IndexShard indexShard) {
    Engine.Delete delete = indexShard.prepareDeleteOnReplica(request.type(), request.id(), request.version(), request.versionType());
    indexShard.delete(delete);
    return delete;
}
 
Example 14
Source File: IndexVersionShardService.java    From siren-join with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void postDeleteUnderLock(Engine.Delete delete) {
  version.incrementAndGet();
}
 
Example 15
Source File: Translog.java    From crate with Apache License 2.0 4 votes vote down vote up
public Delete(Engine.Delete delete, Engine.DeleteResult deleteResult) {
    this(delete.type(), delete.id(), delete.uid(), deleteResult.getSeqNo(), delete.primaryTerm(), deleteResult.getVersion());
}
 
Example 16
Source File: IndexingMemoryController.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void postDelete(ShardId shardId, Engine.Delete delete, Engine.DeleteResult result) {
    recordOperationBytes(delete, result);
}
 
Example 17
Source File: IndexingOperationListener.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Called before the delete occurs.
 */
default Engine.Delete preDelete(ShardId shardId, Engine.Delete delete) {
    return delete;
}
 
Example 18
Source File: IndexingOperationListener.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Called after the delete operation occurred.
 */
public void postDelete(Engine.Delete delete) {

}
 
Example 19
Source File: IndexingOperationListener.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Called after the delete operation occurred with exception.
 */
public void postDelete(Engine.Delete delete, Throwable ex) {

}
 
Example 20
Source File: IndexingOperationListener.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Called after the delete operation occurred with engine level exception.
 * See {@link #postDelete(ShardId, Engine.Delete, Engine.DeleteResult)} for document
 * related failures
 */
default void postDelete(ShardId shardId, Engine.Delete delete, Exception ex) {
}