From b5079ce0092e2dfd742fbe3aed8a8f95931a378d Mon Sep 17 00:00:00 2001 From: Areek Zillur Date: Thu, 6 Oct 2016 05:05:59 -0400 Subject: [PATCH] rename DocumentRequest to DocumentWriteRequest --- .../noop/action/bulk/RestNoopBulkAction.java | 4 +- .../action/bulk/TransportNoopBulkAction.java | 4 +- ...Request.java => DocumentWriteRequest.java} | 6 +-- .../action/bulk/BulkItemRequest.java | 12 ++--- .../action/bulk/BulkItemResponse.java | 2 +- .../action/bulk/BulkProcessor.java | 12 ++--- .../action/bulk/BulkRequest.java | 28 +++++------ .../action/bulk/TransportBulkAction.java | 45 +++++++++--------- .../action/bulk/TransportShardBulkAction.java | 46 +++++++------------ .../action/delete/DeleteRequest.java | 5 +- .../action/delete/TransportDeleteAction.java | 2 - .../action/index/IndexRequest.java | 5 +- .../action/index/IndexRequestBuilder.java | 4 +- .../action/ingest/IngestActionFilter.java | 8 ++-- .../TransportReplicationAction.java | 4 +- .../action/update/UpdateReplicaRequest.java | 17 +++---- .../action/update/UpdateRequest.java | 6 +-- .../org/elasticsearch/index/mapper/Uid.java | 2 - .../ingest/PipelineExecutionService.java | 6 +-- .../action/bulk/BulkRequestTests.java | 4 +- .../action/bulk/BulkWithUpdatesIT.java | 2 +- .../elasticsearch/action/bulk/RetryTests.java | 6 +-- .../action/index/IndexRequestTests.java | 10 ++-- .../ingest/BulkRequestModifierTests.java | 4 +- .../ingest/IngestActionFilterTests.java | 6 +-- .../document/DocumentActionsIT.java | 2 +- .../ingest/PipelineExecutionServiceTests.java | 4 +- .../routing/SimpleRoutingIT.java | 9 ++-- .../versioning/SimpleVersioningIT.java | 7 ++- .../AbstractAsyncBulkIndexByScrollAction.java | 6 +-- .../reindex/AsyncBulkByScrollActionTests.java | 17 ++++--- .../index/reindex/ReindexFailureTests.java | 2 +- .../index/reindex/ReindexVersioningTests.java | 2 +- 33 files changed, 134 insertions(+), 165 deletions(-) rename core/src/main/java/org/elasticsearch/action/{DocumentRequest.java => DocumentWriteRequest.java} (95%) diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java index 466821824a5..3add7b21c23 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/RestNoopBulkAction.java @@ -19,7 +19,7 @@ package org.elasticsearch.plugin.noop.action.bulk; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkShardRequest; @@ -85,7 +85,7 @@ public class RestNoopBulkAction extends BaseRestHandler { } private static class BulkRestBuilderListener extends RestBuilderListener { - private final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocumentRequest.OpType.UPDATE, + private final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocumentWriteRequest.OpType.UPDATE, new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 1L, DocWriteResponse.Result.CREATED)); private final RestRequest request; diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java index 931e6724462..238508cf5df 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java @@ -20,7 +20,7 @@ package org.elasticsearch.plugin.noop.action.bulk; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; @@ -35,7 +35,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; public class TransportNoopBulkAction extends HandledTransportAction { - private static final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocumentRequest.OpType.UPDATE, + private static final BulkItemResponse ITEM_RESPONSE = new BulkItemResponse(1, DocumentWriteRequest.OpType.UPDATE, new UpdateResponse(new ShardId("mock", "", 1), "mock_type", "1", 1L, DocWriteResponse.Result.CREATED)); @Inject diff --git a/core/src/main/java/org/elasticsearch/action/DocumentRequest.java b/core/src/main/java/org/elasticsearch/action/DocumentWriteRequest.java similarity index 95% rename from core/src/main/java/org/elasticsearch/action/DocumentRequest.java rename to core/src/main/java/org/elasticsearch/action/DocumentWriteRequest.java index ef2aa815a6b..66ea6401bcc 100644 --- a/core/src/main/java/org/elasticsearch/action/DocumentRequest.java +++ b/core/src/main/java/org/elasticsearch/action/DocumentWriteRequest.java @@ -34,7 +34,7 @@ import java.util.Locale; * Generic interface to group ActionRequest, which perform writes to a single document * Action requests implementing this can be part of {@link org.elasticsearch.action.bulk.BulkRequest} */ -public abstract class DocumentRequest> extends ReplicatedWriteRequest { +public abstract class DocumentWriteRequest> extends ReplicatedWriteRequest { /** * Get the type that this request operates on @@ -153,7 +153,7 @@ public abstract class DocumentRequest> exten } /** read a document write (index/delete/update) request */ - public static DocumentRequest readDocumentRequest(StreamInput in) throws IOException { + public static DocumentWriteRequest readDocumentRequest(StreamInput in) throws IOException { byte type = in.readByte(); if (type == 0) { IndexRequest indexRequest = new IndexRequest(); @@ -177,7 +177,7 @@ public abstract class DocumentRequest> exten } /** write a document write (index/delete/update) request*/ - public static void writeDocumentRequest(StreamOutput out, DocumentRequest request) throws IOException { + public static void writeDocumentRequest(StreamOutput out, DocumentWriteRequest request) throws IOException { if (request instanceof IndexRequest) { out.writeByte((byte) 0); } else if (request instanceof DeleteRequest) { diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java index df9fd13b034..7ba3c81b5df 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemRequest.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.bulk; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -32,7 +32,7 @@ import java.io.IOException; public class BulkItemRequest implements Streamable { private int id; - private DocumentRequest request; + private DocumentWriteRequest request; private volatile BulkItemResponse primaryResponse; private volatile boolean ignoreOnReplica; @@ -40,7 +40,7 @@ public class BulkItemRequest implements Streamable { } - public BulkItemRequest(int id, DocumentRequest request) { + public BulkItemRequest(int id, DocumentWriteRequest request) { this.id = id; this.request = request; } @@ -49,7 +49,7 @@ public class BulkItemRequest implements Streamable { return id; } - public DocumentRequest request() { + public DocumentWriteRequest request() { return request; } @@ -86,7 +86,7 @@ public class BulkItemRequest implements Streamable { @Override public void readFrom(StreamInput in) throws IOException { id = in.readVInt(); - request = DocumentRequest.readDocumentRequest(in); + request = DocumentWriteRequest.readDocumentRequest(in); if (in.readBoolean()) { primaryResponse = BulkItemResponse.readBulkItem(in); } @@ -96,7 +96,7 @@ public class BulkItemRequest implements Streamable { @Override public void writeTo(StreamOutput out) throws IOException { out.writeVInt(id); - DocumentRequest.writeDocumentRequest(out, request); + DocumentWriteRequest.writeDocumentRequest(out, request); out.writeOptionalStreamable(primaryResponse); out.writeBoolean(ignoreOnReplica); } diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index 9f0714784bc..9129f9b01bf 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -23,7 +23,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.DocumentRequest.OpType; +import org.elasticsearch.action.DocumentWriteRequest.OpType; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.update.UpdateResponse; diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java index f32bfaa775c..ea07136a8c9 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkProcessor.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.bulk; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.client.Client; @@ -250,24 +250,24 @@ public class BulkProcessor implements Closeable { * (for example, if no id is provided, one will be generated, or usage of the create flag). */ public BulkProcessor add(IndexRequest request) { - return add((DocumentRequest) request); + return add((DocumentWriteRequest) request); } /** * Adds an {@link DeleteRequest} to the list of actions to execute. */ public BulkProcessor add(DeleteRequest request) { - return add((DocumentRequest) request); + return add((DocumentWriteRequest) request); } /** * Adds either a delete or an index request. */ - public BulkProcessor add(DocumentRequest request) { + public BulkProcessor add(DocumentWriteRequest request) { return add(request, null); } - public BulkProcessor add(DocumentRequest request, @Nullable Object payload) { + public BulkProcessor add(DocumentWriteRequest request, @Nullable Object payload) { internalAdd(request, payload); return this; } @@ -282,7 +282,7 @@ public class BulkProcessor implements Closeable { } } - private synchronized void internalAdd(DocumentRequest request, @Nullable Object payload) { + private synchronized void internalAdd(DocumentWriteRequest request, @Nullable Object payload) { ensureOpen(); bulkRequest.add(request, payload); executeIfNeeded(); diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 7729c737439..2ec89d55228 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -22,7 +22,7 @@ package org.elasticsearch.action.bulk; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; @@ -72,7 +72,7 @@ public class BulkRequest extends ActionRequest implements Composite * {@link WriteRequest}s to this but java doesn't support syntax to declare that everything in the array has both types so we declare * the one with the least casts. */ - final List> requests = new ArrayList<>(); + final List> requests = new ArrayList<>(); List payloads = null; protected TimeValue timeout = BulkShardRequest.DEFAULT_TIMEOUT; @@ -87,14 +87,14 @@ public class BulkRequest extends ActionRequest implements Composite /** * Adds a list of requests to be executed. Either index or delete requests. */ - public BulkRequest add(DocumentRequest... requests) { - for (DocumentRequest request : requests) { + public BulkRequest add(DocumentWriteRequest... requests) { + for (DocumentWriteRequest request : requests) { add(request, null); } return this; } - public BulkRequest add(DocumentRequest request) { + public BulkRequest add(DocumentWriteRequest request) { return add(request, null); } @@ -104,7 +104,7 @@ public class BulkRequest extends ActionRequest implements Composite * @param payload Optional payload * @return the current bulk request */ - public BulkRequest add(DocumentRequest request, @Nullable Object payload) { + public BulkRequest add(DocumentWriteRequest request, @Nullable Object payload) { if (request instanceof IndexRequest) { add((IndexRequest) request, payload); } else if (request instanceof DeleteRequest) { @@ -120,8 +120,8 @@ public class BulkRequest extends ActionRequest implements Composite /** * Adds a list of requests to be executed. Either index or delete requests. */ - public BulkRequest add(Iterable> requests) { - for (DocumentRequest request : requests) { + public BulkRequest add(Iterable> requests) { + for (DocumentWriteRequest request : requests) { add(request); } return this; @@ -207,7 +207,7 @@ public class BulkRequest extends ActionRequest implements Composite /** * The list of requests in this bulk request. */ - public List> requests() { + public List> requests() { return this.requests; } @@ -508,7 +508,7 @@ public class BulkRequest extends ActionRequest implements Composite * @return Whether this bulk request contains index request with an ingest pipeline enabled. */ public boolean hasIndexRequestsWithPipelines() { - for (DocumentRequest actionRequest : requests) { + for (DocumentWriteRequest actionRequest : requests) { if (actionRequest instanceof IndexRequest) { IndexRequest indexRequest = (IndexRequest) actionRequest; if (Strings.hasText(indexRequest.getPipeline())) { @@ -526,7 +526,7 @@ public class BulkRequest extends ActionRequest implements Composite if (requests.isEmpty()) { validationException = addValidationError("no requests added", validationException); } - for (DocumentRequest request : requests) { + for (DocumentWriteRequest request : requests) { // We first check if refresh has been set if (request.getRefreshPolicy() != RefreshPolicy.NONE) { validationException = addValidationError( @@ -550,7 +550,7 @@ public class BulkRequest extends ActionRequest implements Composite waitForActiveShards = ActiveShardCount.readFrom(in); int size = in.readVInt(); for (int i = 0; i < size; i++) { - requests.add(DocumentRequest.readDocumentRequest(in)); + requests.add(DocumentWriteRequest.readDocumentRequest(in)); } refreshPolicy = RefreshPolicy.readFrom(in); timeout = new TimeValue(in); @@ -561,8 +561,8 @@ public class BulkRequest extends ActionRequest implements Composite super.writeTo(out); waitForActiveShards.writeTo(out); out.writeVInt(requests.size()); - for (DocumentRequest request : requests) { - DocumentRequest.writeDocumentRequest(out, request); + for (DocumentWriteRequest request : requests) { + DocumentWriteRequest.writeDocumentRequest(out, request); } refreshPolicy.writeTo(out); timeout.writeTo(out); diff --git a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java index 37c1b7c2290..f7ea0033b5b 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/TransportBulkAction.java @@ -22,12 +22,11 @@ package org.elasticsearch.action.bulk; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; -import org.elasticsearch.action.delete.TransportDeleteAction; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.AutoCreateIndex; @@ -116,7 +115,7 @@ public class TransportBulkAction extends HandledTransportAction autoCreateIndices = bulkRequest.requests.stream() - .map(DocumentRequest::index) + .map(DocumentWriteRequest::index) .collect(Collectors.toSet()); final AtomicInteger counter = new AtomicInteger(autoCreateIndices.size()); ClusterState state = clusterService.state(); @@ -143,7 +142,7 @@ public class TransportBulkAction extends HandledTransportAction request = bulkRequest.requests.get(i); + DocumentWriteRequest request = bulkRequest.requests.get(i); if (request != null && setResponseFailureIfIndexMatches(responses, i, request, index, e)) { bulkRequest.requests.set(i, null); } @@ -178,7 +177,7 @@ public class TransportBulkAction extends HandledTransportAction responses, int idx, DocumentRequest request, String index, Exception e) { + private boolean setResponseFailureIfIndexMatches(AtomicArray responses, int idx, DocumentWriteRequest request, String index, Exception e) { if (index.equals(request.index())) { responses.set(idx, new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.type(), request.id(), e))); return true; @@ -209,20 +208,20 @@ public class TransportBulkAction extends HandledTransportAction Operations mapping Map> requestsByShard = new HashMap<>(); for (int i = 0; i < bulkRequest.requests.size(); i++) { - DocumentRequest request = bulkRequest.requests.get(i); + DocumentWriteRequest request = bulkRequest.requests.get(i); if (request == null) { continue; } @@ -296,9 +295,9 @@ public class TransportBulkAction extends HandledTransportAction documentRequest = request.request(); - responses.set(request.id(), new BulkItemResponse(request.id(), documentRequest.opType(), - new BulkItemResponse.Failure(indexName, documentRequest.type(), documentRequest.id(), e))); + DocumentWriteRequest documentWriteRequest = request.request(); + responses.set(request.id(), new BulkItemResponse(request.id(), documentWriteRequest.opType(), + new BulkItemResponse.Failure(indexName, documentWriteRequest.type(), documentWriteRequest.id(), e))); } if (counter.decrementAndGet() == 0) { finishHim(); @@ -312,9 +311,9 @@ public class TransportBulkAction extends HandledTransportAction responses, int idx, - final ConcreteIndices concreteIndices, - final MetaData metaData) { + private boolean addFailureIfIndexIsUnavailable(DocumentWriteRequest request, BulkRequest bulkRequest, AtomicArray responses, int idx, + final ConcreteIndices concreteIndices, + final MetaData metaData) { Index concreteIndex = concreteIndices.getConcreteIndex(request.index()); Exception unavailableException = null; if (concreteIndex == null) { @@ -358,7 +357,7 @@ public class TransportBulkAction extends HandledTransportAction itemRequest = request.items()[requestIndex].request(); + DocumentWriteRequest itemRequest = request.items()[requestIndex].request(); preVersions[requestIndex] = itemRequest.version(); preVersionTypes[requestIndex] = itemRequest.versionType(); - DocumentRequest.OpType opType = itemRequest.opType(); + DocumentWriteRequest.OpType opType = itemRequest.opType(); try { final WriteResult writeResult; switch (itemRequest.opType()) { @@ -210,7 +198,7 @@ public class TransportShardBulkAction extends TransportWriteAction) writeResult.getReplicaRequest()); + (DocumentWriteRequest) writeResult.getReplicaRequest()); // add the response setResponse(request.items()[requestIndex], new BulkItemResponse(request.items()[requestIndex].id(), opType, writeResult.getResponse())); } catch (Exception e) { @@ -218,20 +206,20 @@ public class TransportShardBulkAction extends TransportWriteAction documentRequest = request.items()[j].request(); - documentRequest.version(preVersions[j]); - documentRequest.versionType(preVersionTypes[j]); + DocumentWriteRequest documentWriteRequest = request.items()[j].request(); + documentWriteRequest.version(preVersions[j]); + documentWriteRequest.versionType(preVersionTypes[j]); } throw (ElasticsearchException) e; } BulkItemRequest item = request.items()[requestIndex]; - DocumentRequest documentRequest = item.request(); + DocumentWriteRequest documentWriteRequest = item.request(); if (isConflictException(e)) { logger.trace((Supplier) () -> new ParameterizedMessage("{} failed to execute bulk item ({}) {}", - request.shardId(), documentRequest.opType().getLowercase(), request), e); + request.shardId(), documentWriteRequest.opType().getLowercase(), request), e); } else { logger.debug((Supplier) () -> new ParameterizedMessage("{} failed to execute bulk item ({}) {}", - request.shardId(), documentRequest.opType().getLowercase(), request), e); + request.shardId(), documentWriteRequest.opType().getLowercase(), request), e); } // if its a conflict failure, and we already executed the request on a primary (and we execute it // again, due to primary relocation and only processing up to N bulk items when the shard gets closed) @@ -239,8 +227,8 @@ public class TransportShardBulkAction extends TransportWriteAction { +public class DeleteRequest extends DocumentWriteRequest { private String type; private String id; diff --git a/core/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java b/core/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java index 926700e327e..d3cb4d24831 100644 --- a/core/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java +++ b/core/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java @@ -21,8 +21,6 @@ package org.elasticsearch.action.delete; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocumentRequest; -import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; diff --git a/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 48eaab2b48c..264b7e0a844 100644 --- a/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -21,10 +21,9 @@ package org.elasticsearch.action.index; import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.action.TimestampParsingException; -import org.elasticsearch.action.support.replication.ReplicatedWriteRequest; import org.elasticsearch.client.Requests; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.metadata.MetaData; @@ -67,7 +66,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError; * @see org.elasticsearch.client.Requests#indexRequest(String) * @see org.elasticsearch.client.Client#index(IndexRequest) */ -public class IndexRequest extends DocumentRequest { +public class IndexRequest extends DocumentWriteRequest { private String type; private String id; diff --git a/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java index a9d8bcaa56b..3291f219a9c 100644 --- a/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/index/IndexRequestBuilder.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.index; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.support.WriteRequestBuilder; import org.elasticsearch.action.support.replication.ReplicationRequestBuilder; import org.elasticsearch.client.ElasticsearchClient; @@ -201,7 +201,7 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder> { + static final class BulkRequestModifier implements Iterator> { final BulkRequest bulkRequest; final Set failedSlots; @@ -151,7 +151,7 @@ public final class IngestActionFilter extends AbstractComponent implements Actio } @Override - public DocumentRequest next() { + public DocumentWriteRequest next() { return bulkRequest.requests().get(++currentSlot); } @@ -172,7 +172,7 @@ public final class IngestActionFilter extends AbstractComponent implements Actio int slot = 0; originalSlots = new int[bulkRequest.requests().size() - failedSlots.size()]; for (int i = 0; i < bulkRequest.requests().size(); i++) { - DocumentRequest request = bulkRequest.requests().get(i); + DocumentWriteRequest request = bulkRequest.requests().get(i); if (failedSlots.contains(i) == false) { modifiedBulkRequest.add(request); originalSlots[slot++] = i; diff --git a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java index 95e196672d4..cab7f1606b8 100644 --- a/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java +++ b/core/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java @@ -23,7 +23,7 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListenerResponseHandler; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.action.UnavailableShardsException; import org.elasticsearch.action.support.ActionFilters; @@ -167,7 +167,7 @@ public abstract class TransportReplicationAction< /** helper to verify and resolve request routing */ public static void resolveAndValidateRouting(final MetaData metaData, final String concreteIndex, - DocumentRequest request) { + DocumentWriteRequest request) { request.routing(metaData.resolveIndexRouting(request.parent(), request.routing(), request.index())); // check if routing is required, if so, throw error if routing wasn't specified if (request.routing() == null && metaData.routingRequired(concreteIndex, request.type())) { diff --git a/core/src/main/java/org/elasticsearch/action/update/UpdateReplicaRequest.java b/core/src/main/java/org/elasticsearch/action/update/UpdateReplicaRequest.java index 5f258a675c2..1eaf3c698fd 100644 --- a/core/src/main/java/org/elasticsearch/action/update/UpdateReplicaRequest.java +++ b/core/src/main/java/org/elasticsearch/action/update/UpdateReplicaRequest.java @@ -19,10 +19,7 @@ package org.elasticsearch.action.update; -import org.elasticsearch.action.DocumentRequest; -import org.elasticsearch.action.delete.DeleteRequest; -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.support.replication.ReplicatedWriteRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.index.VersionType; @@ -30,13 +27,13 @@ import org.elasticsearch.index.VersionType; import java.io.IOException; /** Replica request for update operation holds translated (index/delete) requests */ -public class UpdateReplicaRequest extends DocumentRequest { - private DocumentRequest request; +public class UpdateReplicaRequest extends DocumentWriteRequest { + private DocumentWriteRequest request; public UpdateReplicaRequest() { } - public UpdateReplicaRequest(DocumentRequest request) { + public UpdateReplicaRequest(DocumentWriteRequest request) { assert !(request instanceof UpdateReplicaRequest) : "underlying request must not be a update replica request"; this.request = request; this.index = request.index(); @@ -45,20 +42,20 @@ public class UpdateReplicaRequest extends DocumentRequest setParentTask(request.getParentTask()); } - public DocumentRequest getRequest() { + public DocumentWriteRequest getRequest() { return request; } @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - request = DocumentRequest.readDocumentRequest(in); + request = DocumentWriteRequest.readDocumentRequest(in); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - DocumentRequest.writeDocumentRequest(out, request); + DocumentWriteRequest.writeDocumentRequest(out, request); } @Override diff --git a/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java index 80d3676e051..d00f7c046f6 100644 --- a/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java +++ b/core/src/main/java/org/elasticsearch/action/update/UpdateRequest.java @@ -20,7 +20,7 @@ package org.elasticsearch.action.update; import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.common.Nullable; @@ -29,8 +29,6 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -53,7 +51,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError; /** */ -public class UpdateRequest extends DocumentRequest { +public class UpdateRequest extends DocumentWriteRequest { private String type; private String id; diff --git a/core/src/main/java/org/elasticsearch/index/mapper/Uid.java b/core/src/main/java/org/elasticsearch/index/mapper/Uid.java index 2a8938b4ab7..344c8dc0cc0 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/Uid.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/Uid.java @@ -21,12 +21,10 @@ package org.elasticsearch.index.mapper; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; -import org.elasticsearch.action.DocumentRequest; import org.elasticsearch.common.lucene.BytesRefs; import java.util.Collection; import java.util.Collections; -import java.util.List; /** * diff --git a/core/src/main/java/org/elasticsearch/ingest/PipelineExecutionService.java b/core/src/main/java/org/elasticsearch/ingest/PipelineExecutionService.java index 57eb7afcb5a..2a5217a9f25 100644 --- a/core/src/main/java/org/elasticsearch/ingest/PipelineExecutionService.java +++ b/core/src/main/java/org/elasticsearch/ingest/PipelineExecutionService.java @@ -19,7 +19,7 @@ package org.elasticsearch.ingest; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterStateListener; @@ -68,7 +68,7 @@ public class PipelineExecutionService implements ClusterStateListener { }); } - public void executeBulkRequest(Iterable> actionRequests, + public void executeBulkRequest(Iterable> actionRequests, BiConsumer itemFailureHandler, Consumer completionHandler) { threadPool.executor(ThreadPool.Names.BULK).execute(new AbstractRunnable() { @@ -80,7 +80,7 @@ public class PipelineExecutionService implements ClusterStateListener { @Override protected void doRun() throws Exception { - for (DocumentRequest actionRequest : actionRequests) { + for (DocumentWriteRequest actionRequest : actionRequests) { if ((actionRequest instanceof IndexRequest)) { IndexRequest indexRequest = (IndexRequest) actionRequest; if (Strings.hasText(indexRequest.getPipeline())) { diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java index 230373f7415..f0d4f35ff56 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java @@ -21,7 +21,7 @@ package org.elasticsearch.action.bulk; import org.apache.lucene.util.Constants; import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; @@ -113,7 +113,7 @@ public class BulkRequestTests extends ESTestCase { public void testBulkAddIterable() { BulkRequest bulkRequest = Requests.bulkRequest(); - List> requests = new ArrayList<>(); + List> requests = new ArrayList<>(); requests.add(new IndexRequest("test", "test", "id").source("field", "value")); requests.add(new UpdateRequest("test", "test", "id").doc("field", "value")); requests.add(new DeleteRequest("test", "test", "id")); diff --git a/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java b/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java index 590a503a654..0e2fec98abc 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/BulkWithUpdatesIT.java @@ -47,7 +47,7 @@ import java.util.Map; import java.util.concurrent.CyclicBarrier; import java.util.function.Function; -import static org.elasticsearch.action.DocumentRequest.OpType; +import static org.elasticsearch.action.DocumentWriteRequest.OpType; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.script.ScriptService.ScriptType; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; diff --git a/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java b/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java index 72bdc8a58f9..7d79a91eb17 100644 --- a/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java +++ b/core/src/test/java/org/elasticsearch/action/bulk/RetryTests.java @@ -20,12 +20,8 @@ package org.elasticsearch.action.bulk; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.DocumentRequest; -import org.elasticsearch.action.DocumentRequest.OpType; -import org.elasticsearch.action.delete.DeleteRequest; +import org.elasticsearch.action.DocumentWriteRequest.OpType; import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.common.unit.TimeValue; diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index da25ec4261f..94fa533a674 100644 --- a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -19,7 +19,7 @@ package org.elasticsearch.action.index; import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.support.replication.ReplicationResponse; import org.elasticsearch.common.unit.TimeValue; @@ -49,13 +49,13 @@ public class IndexRequestTests extends ESTestCase { IndexRequest indexRequest = new IndexRequest(""); indexRequest.opType(create); - assertThat(indexRequest.opType() , equalTo(DocumentRequest.OpType.CREATE)); + assertThat(indexRequest.opType() , equalTo(DocumentWriteRequest.OpType.CREATE)); indexRequest.opType(createUpper); - assertThat(indexRequest.opType() , equalTo(DocumentRequest.OpType.CREATE)); + assertThat(indexRequest.opType() , equalTo(DocumentWriteRequest.OpType.CREATE)); indexRequest.opType(index); - assertThat(indexRequest.opType() , equalTo(DocumentRequest.OpType.INDEX)); + assertThat(indexRequest.opType() , equalTo(DocumentWriteRequest.OpType.INDEX)); indexRequest.opType(indexUpper); - assertThat(indexRequest.opType() , equalTo(DocumentRequest.OpType.INDEX)); + assertThat(indexRequest.opType() , equalTo(DocumentWriteRequest.OpType.INDEX)); } public void testReadBogusString() { diff --git a/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java b/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java index 8dac5853cac..87adf3cf5b9 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/BulkRequestModifierTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.action.ingest; */ import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.bulk.BulkItemResponse; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.bulk.BulkResponse; @@ -116,7 +116,7 @@ public class BulkRequestModifierTests extends ESTestCase { }); List originalResponses = new ArrayList<>(); - for (DocumentRequest actionRequest : bulkRequest.requests()) { + for (DocumentWriteRequest actionRequest : bulkRequest.requests()) { IndexRequest indexRequest = (IndexRequest) actionRequest; IndexResponse indexResponse = new IndexResponse(new ShardId("index", "_na_", 0), indexRequest.type(), indexRequest.id(), 1, true); originalResponses.add(new BulkItemResponse(Integer.parseInt(indexRequest.id()), indexRequest.opType(), indexResponse)); diff --git a/core/src/test/java/org/elasticsearch/action/ingest/IngestActionFilterTests.java b/core/src/test/java/org/elasticsearch/action/ingest/IngestActionFilterTests.java index 2b9f9c55320..2ead142521d 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/IngestActionFilterTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/IngestActionFilterTests.java @@ -20,7 +20,7 @@ package org.elasticsearch.action.ingest; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.bulk.BulkAction; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.delete.DeleteRequest; @@ -174,7 +174,7 @@ public class IngestActionFilterTests extends ESTestCase { int numRequest = scaledRandomIntBetween(8, 64); for (int i = 0; i < numRequest; i++) { if (rarely()) { - DocumentRequest request; + DocumentWriteRequest request; if (randomBoolean()) { request = new DeleteRequest("_index", "_type", "_id"); } else { @@ -196,7 +196,7 @@ public class IngestActionFilterTests extends ESTestCase { verifyZeroInteractions(actionListener); int assertedRequests = 0; - for (DocumentRequest actionRequest : bulkRequest.requests()) { + for (DocumentWriteRequest actionRequest : bulkRequest.requests()) { if (actionRequest instanceof IndexRequest) { IndexRequest indexRequest = (IndexRequest) actionRequest; assertThat(indexRequest.sourceAsMap().size(), equalTo(2)); diff --git a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java index d198529f8d4..ac67a86a714 100644 --- a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java +++ b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java @@ -37,7 +37,7 @@ import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; import java.io.IOException; -import static org.elasticsearch.action.DocumentRequest.OpType; +import static org.elasticsearch.action.DocumentWriteRequest.OpType; import static org.elasticsearch.client.Requests.clearIndicesCacheRequest; import static org.elasticsearch.client.Requests.getRequest; import static org.elasticsearch.client.Requests.indexRequest; diff --git a/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java b/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java index 8b22e4f0bc8..a1a6d612850 100644 --- a/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/PipelineExecutionServiceTests.java @@ -21,7 +21,7 @@ package org.elasticsearch.ingest; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; @@ -317,7 +317,7 @@ public class PipelineExecutionServiceTests extends ESTestCase { int numRequest = scaledRandomIntBetween(8, 64); int numIndexRequests = 0; for (int i = 0; i < numRequest; i++) { - DocumentRequest request; + DocumentWriteRequest request; if (randomBoolean()) { if (randomBoolean()) { request = new DeleteRequest("_index", "_type", "_id"); diff --git a/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index 5980f781e2e..eaa107c14ed 100644 --- a/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/core/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -20,8 +20,7 @@ package org.elasticsearch.routing; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.RoutingMissingException; import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.bulk.BulkItemResponse; @@ -261,7 +260,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { for (BulkItemResponse bulkItemResponse : bulkResponse) { assertThat(bulkItemResponse.isFailed(), equalTo(true)); - assertThat(bulkItemResponse.getOpType(), equalTo(DocumentRequest.OpType.INDEX)); + assertThat(bulkItemResponse.getOpType(), equalTo(DocumentWriteRequest.OpType.INDEX)); assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST)); assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class)); assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]")); @@ -282,7 +281,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { for (BulkItemResponse bulkItemResponse : bulkResponse) { assertThat(bulkItemResponse.isFailed(), equalTo(true)); - assertThat(bulkItemResponse.getOpType(), equalTo(DocumentRequest.OpType.UPDATE)); + assertThat(bulkItemResponse.getOpType(), equalTo(DocumentWriteRequest.OpType.UPDATE)); assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST)); assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class)); assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]")); @@ -303,7 +302,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { for (BulkItemResponse bulkItemResponse : bulkResponse) { assertThat(bulkItemResponse.isFailed(), equalTo(true)); - assertThat(bulkItemResponse.getOpType(), equalTo(DocumentRequest.OpType.DELETE)); + assertThat(bulkItemResponse.getOpType(), equalTo(DocumentWriteRequest.OpType.DELETE)); assertThat(bulkItemResponse.getFailure().getStatus(), equalTo(RestStatus.BAD_REQUEST)); assertThat(bulkItemResponse.getFailure().getCause(), instanceOf(RoutingMissingException.class)); assertThat(bulkItemResponse.getFailureMessage(), containsString("routing is required for [test]/[type1]/[1]")); diff --git a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java index 417defee5fa..a0326a2cc2c 100644 --- a/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java +++ b/core/src/test/java/org/elasticsearch/versioning/SimpleVersioningIT.java @@ -21,10 +21,9 @@ package org.elasticsearch.versioning; import org.apache.lucene.util.TestUtil; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.DocWriteResponse; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.delete.DeleteResponse; -import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.lucene.uid.Versions; @@ -690,7 +689,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { client() .prepareIndex("test", "type", "id") .setSource("foo", "bar") - .setOpType(DocumentRequest.OpType.INDEX) + .setOpType(DocumentWriteRequest.OpType.INDEX) .setVersion(10) .setVersionType(VersionType.EXTERNAL) .execute() @@ -759,7 +758,7 @@ public class SimpleVersioningIT extends ESIntegTestCase { client() .prepareIndex("test", "type", "id") .setSource("foo", "bar") - .setOpType(DocumentRequest.OpType.INDEX) + .setOpType(DocumentWriteRequest.OpType.INDEX) .setVersion(10) .setVersionType(VersionType.EXTERNAL) .execute() diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java index 1f135500dfd..8c95b7b2f86 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.reindex; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.index.IndexRequest; @@ -154,9 +154,9 @@ public abstract class AbstractAsyncBulkIndexByScrollAction> { + interface RequestWrapper> { void setIndex(String index); diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java index 4ea7f039970..797f2bcb4dc 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/AsyncBulkByScrollActionTests.java @@ -29,7 +29,7 @@ import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.DocWriteResponse.Result; -import org.elasticsearch.action.DocumentRequest; +import org.elasticsearch.action.DocumentWriteRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.bulk.BackoffPolicy; import org.elasticsearch.action.bulk.BulkItemResponse; @@ -49,7 +49,6 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchScrollRequest; import org.elasticsearch.action.search.ShardSearchFailure; import org.elasticsearch.action.support.PlainActionFuture; -import org.elasticsearch.action.support.replication.ReplicationRequest; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.Client; @@ -261,27 +260,27 @@ public class AsyncBulkByScrollActionTests extends ESTestCase { ShardId shardId = new ShardId(new Index("name", "uid"), 0); if (rarely()) { versionConflicts++; - responses[i] = new BulkItemResponse(i, randomFrom(DocumentRequest.OpType.values()), + responses[i] = new BulkItemResponse(i, randomFrom(DocumentWriteRequest.OpType.values()), new Failure(shardId.getIndexName(), "type", "id" + i, new VersionConflictEngineException(shardId, "type", "id", "test"))); continue; } boolean createdResponse; - DocumentRequest.OpType opType; + DocumentWriteRequest.OpType opType; switch (randomIntBetween(0, 2)) { case 0: createdResponse = true; - opType = DocumentRequest.OpType.CREATE; + opType = DocumentWriteRequest.OpType.CREATE; created++; break; case 1: createdResponse = false; - opType = randomFrom(DocumentRequest.OpType.INDEX, DocumentRequest.OpType.UPDATE); + opType = randomFrom(DocumentWriteRequest.OpType.INDEX, DocumentWriteRequest.OpType.UPDATE); updated++; break; case 2: createdResponse = false; - opType = DocumentRequest.OpType.DELETE; + opType = DocumentWriteRequest.OpType.DELETE; deleted++; break; default: @@ -363,7 +362,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase { Failure failure = new Failure("index", "type", "id", new RuntimeException("test")); DummyAbstractAsyncBulkByScrollAction action = new DummyAbstractAsyncBulkByScrollAction(); BulkResponse bulkResponse = new BulkResponse(new BulkItemResponse[] - {new BulkItemResponse(0, DocumentRequest.OpType.CREATE, failure)}, randomLong()); + {new BulkItemResponse(0, DocumentWriteRequest.OpType.CREATE, failure)}, randomLong()); action.onBulkResponse(timeValueNanos(System.nanoTime()), bulkResponse); BulkIndexByScrollResponse response = listener.get(); assertThat(response.getBulkFailures(), contains(failure)); @@ -769,7 +768,7 @@ public class AsyncBulkByScrollActionTests extends ESTestCase { } BulkItemResponse[] responses = new BulkItemResponse[bulk.requests().size()]; for (int i = 0; i < bulk.requests().size(); i++) { - DocumentRequest item = bulk.requests().get(i); + DocumentWriteRequest item = bulk.requests().get(i); DocWriteResponse response; ShardId shardId = new ShardId(new Index(item.index(), "uuid"), 0); if (item instanceof IndexRequest) { diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFailureTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFailureTests.java index c909ea42ecb..3bca1a2014f 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFailureTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexFailureTests.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import static org.elasticsearch.action.DocumentRequest.OpType.CREATE; +import static org.elasticsearch.action.DocumentWriteRequest.OpType.CREATE; import static org.hamcrest.Matchers.both; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.either; diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java index 041c796b173..befd9c7cdc2 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexVersioningTests.java @@ -21,7 +21,7 @@ package org.elasticsearch.index.reindex; import org.elasticsearch.action.get.GetResponse; -import static org.elasticsearch.action.DocumentRequest.OpType.CREATE; +import static org.elasticsearch.action.DocumentWriteRequest.OpType.CREATE; import static org.elasticsearch.index.VersionType.EXTERNAL; import static org.elasticsearch.index.VersionType.INTERNAL;