rename DocumentRequest to DocumentWriteRequest
This commit is contained in:
parent
eee0d18f94
commit
b5079ce009
|
@ -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<BulkRequest> {
|
||||
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;
|
||||
|
|
|
@ -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<BulkRequest, BulkResponse> {
|
||||
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
|
||||
|
|
|
@ -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<T extends ReplicatedWriteRequest<T>> extends ReplicatedWriteRequest<T> {
|
||||
public abstract class DocumentWriteRequest<T extends ReplicatedWriteRequest<T>> extends ReplicatedWriteRequest<T> {
|
||||
|
||||
/**
|
||||
* Get the type that this request operates on
|
||||
|
@ -153,7 +153,7 @@ public abstract class DocumentRequest<T extends ReplicatedWriteRequest<T>> 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<T extends ReplicatedWriteRequest<T>> 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) {
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<BulkRequest> 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<DocumentRequest<?>> requests = new ArrayList<>();
|
||||
final List<DocumentWriteRequest<?>> requests = new ArrayList<>();
|
||||
List<Object> payloads = null;
|
||||
|
||||
protected TimeValue timeout = BulkShardRequest.DEFAULT_TIMEOUT;
|
||||
|
@ -87,14 +87,14 @@ public class BulkRequest extends ActionRequest<BulkRequest> 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<BulkRequest> 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<BulkRequest> implements Composite
|
|||
/**
|
||||
* Adds a list of requests to be executed. Either index or delete requests.
|
||||
*/
|
||||
public BulkRequest add(Iterable<DocumentRequest<?>> requests) {
|
||||
for (DocumentRequest<?> request : requests) {
|
||||
public BulkRequest add(Iterable<DocumentWriteRequest<?>> requests) {
|
||||
for (DocumentWriteRequest<?> request : requests) {
|
||||
add(request);
|
||||
}
|
||||
return this;
|
||||
|
@ -207,7 +207,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> implements Composite
|
|||
/**
|
||||
* The list of requests in this bulk request.
|
||||
*/
|
||||
public List<DocumentRequest<?>> requests() {
|
||||
public List<DocumentWriteRequest<?>> requests() {
|
||||
return this.requests;
|
||||
}
|
||||
|
||||
|
@ -508,7 +508,7 @@ public class BulkRequest extends ActionRequest<BulkRequest> 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<BulkRequest> 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<BulkRequest> 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<BulkRequest> 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);
|
||||
|
|
|
@ -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<BulkRequest, Bul
|
|||
if (needToCheck()) {
|
||||
// Keep track of all unique indices and all unique types per index for the create index requests:
|
||||
final Set<String> 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<BulkRequest, Bul
|
|||
if (!(ExceptionsHelper.unwrapCause(e) instanceof IndexAlreadyExistsException)) {
|
||||
// fail all requests involving this index, if create didnt work
|
||||
for (int i = 0; i < bulkRequest.requests.size(); i++) {
|
||||
DocumentRequest<?> 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<BulkRequest, Bul
|
|||
return autoCreateIndex.shouldAutoCreate(index, state);
|
||||
}
|
||||
|
||||
private boolean setResponseFailureIfIndexMatches(AtomicArray<BulkItemResponse> responses, int idx, DocumentRequest<?> request, String index, Exception e) {
|
||||
private boolean setResponseFailureIfIndexMatches(AtomicArray<BulkItemResponse> 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<BulkRequest, Bul
|
|||
final ConcreteIndices concreteIndices = new ConcreteIndices(clusterState, indexNameExpressionResolver);
|
||||
MetaData metaData = clusterState.metaData();
|
||||
for (int i = 0; i < bulkRequest.requests.size(); i++) {
|
||||
DocumentRequest documentRequest = bulkRequest.requests.get(i);
|
||||
DocumentWriteRequest documentWriteRequest = bulkRequest.requests.get(i);
|
||||
//the request can only be null because we set it to null in the previous step, so it gets ignored
|
||||
if (documentRequest == null) {
|
||||
if (documentWriteRequest == null) {
|
||||
continue;
|
||||
}
|
||||
if (addFailureIfIndexIsUnavailable(documentRequest, bulkRequest, responses, i, concreteIndices, metaData)) {
|
||||
if (addFailureIfIndexIsUnavailable(documentWriteRequest, bulkRequest, responses, i, concreteIndices, metaData)) {
|
||||
continue;
|
||||
}
|
||||
Index concreteIndex = concreteIndices.resolveIfAbsent(documentRequest);
|
||||
Index concreteIndex = concreteIndices.resolveIfAbsent(documentWriteRequest);
|
||||
try {
|
||||
switch (documentRequest.opType()) {
|
||||
switch (documentWriteRequest.opType()) {
|
||||
case CREATE:
|
||||
case INDEX:
|
||||
IndexRequest indexRequest = (IndexRequest) documentRequest;
|
||||
IndexRequest indexRequest = (IndexRequest) documentWriteRequest;
|
||||
MappingMetaData mappingMd = null;
|
||||
final IndexMetaData indexMetaData = metaData.index(concreteIndex);
|
||||
if (indexMetaData != null) {
|
||||
|
@ -233,13 +232,13 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
break;
|
||||
case UPDATE:
|
||||
case DELETE:
|
||||
TransportWriteAction.resolveAndValidateRouting(metaData, concreteIndex.getName(), documentRequest);
|
||||
TransportWriteAction.resolveAndValidateRouting(metaData, concreteIndex.getName(), documentWriteRequest);
|
||||
break;
|
||||
default: throw new AssertionError("request type not supported: [" + documentRequest.opType() + "]");
|
||||
default: throw new AssertionError("request type not supported: [" + documentWriteRequest.opType() + "]");
|
||||
}
|
||||
} catch (ElasticsearchParseException | RoutingMissingException e) {
|
||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), documentRequest.type(), documentRequest.id(), e);
|
||||
BulkItemResponse bulkItemResponse = new BulkItemResponse(i, documentRequest.opType(), failure);
|
||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), documentWriteRequest.type(), documentWriteRequest.id(), e);
|
||||
BulkItemResponse bulkItemResponse = new BulkItemResponse(i, documentWriteRequest.opType(), failure);
|
||||
responses.set(i, bulkItemResponse);
|
||||
// make sure the request gets never processed again
|
||||
bulkRequest.requests.set(i, null);
|
||||
|
@ -249,7 +248,7 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
// first, go over all the requests and create a ShardId -> Operations mapping
|
||||
Map<ShardId, List<BulkItemRequest>> 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<BulkRequest, Bul
|
|||
// create failures for all relevant requests
|
||||
for (BulkItemRequest request : requests) {
|
||||
final String indexName = concreteIndices.getConcreteIndex(request.index()).getName();
|
||||
DocumentRequest<?> 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<BulkRequest, Bul
|
|||
}
|
||||
}
|
||||
|
||||
private boolean addFailureIfIndexIsUnavailable(DocumentRequest request, BulkRequest bulkRequest, AtomicArray<BulkItemResponse> responses, int idx,
|
||||
final ConcreteIndices concreteIndices,
|
||||
final MetaData metaData) {
|
||||
private boolean addFailureIfIndexIsUnavailable(DocumentWriteRequest request, BulkRequest bulkRequest, AtomicArray<BulkItemResponse> 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<BulkRequest, Bul
|
|||
return indices.get(indexOrAlias);
|
||||
}
|
||||
|
||||
Index resolveIfAbsent(DocumentRequest request) {
|
||||
Index resolveIfAbsent(DocumentWriteRequest request) {
|
||||
Index concreteIndex = indices.get(request.index());
|
||||
if (concreteIndex == null) {
|
||||
concreteIndex = indexNameExpressionResolver.concreteSingleIndex(state, request);
|
||||
|
|
|
@ -25,15 +25,13 @@ import org.elasticsearch.ElasticsearchException;
|
|||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.DocumentRequest;
|
||||
import org.elasticsearch.action.DocumentWriteRequest;
|
||||
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.DeleteRequest;
|
||||
import org.elasticsearch.action.delete.DeleteResponse;
|
||||
import org.elasticsearch.action.delete.TransportDeleteAction;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.index.TransportIndexAction;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.AutoCreateIndex;
|
||||
|
@ -44,39 +42,29 @@ import org.elasticsearch.action.update.TransportUpdateAction;
|
|||
import org.elasticsearch.action.update.UpdateHelper;
|
||||
import org.elasticsearch.action.update.UpdateReplicaRequest;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.action.index.MappingUpdatedAction;
|
||||
import org.elasticsearch.cluster.action.shard.ShardStateAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.engine.VersionConflictEngineException;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.index.translog.Translog;
|
||||
import org.elasticsearch.index.translog.Translog.Location;
|
||||
import org.elasticsearch.indices.IndexAlreadyExistsException;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportRequestOptions;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.elasticsearch.action.support.replication.ReplicationOperation.ignoreReplicaException;
|
||||
import static org.elasticsearch.action.support.replication.ReplicationOperation.isConflictException;
|
||||
|
||||
|
@ -180,10 +168,10 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
BulkShardRequest request,
|
||||
long[] preVersions, VersionType[] preVersionTypes,
|
||||
Translog.Location location, int requestIndex) {
|
||||
DocumentRequest<?> 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<? extends ReplicatedWriteRequest, ? extends DocWriteResponse> writeResult;
|
||||
switch (itemRequest.opType()) {
|
||||
|
@ -210,7 +198,7 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
}
|
||||
// update the bulk item request with replica request (update request are changed to index or delete requests for replication)
|
||||
request.items()[requestIndex] = new BulkItemRequest(request.items()[requestIndex].id(),
|
||||
(DocumentRequest<?>) 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<BulkShardRequ
|
|||
if (retryPrimaryException(e)) {
|
||||
// restore updated versions...
|
||||
for (int j = 0; j < requestIndex; j++) {
|
||||
DocumentRequest<?> 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<BulkShardRequ
|
|||
if (item.getPrimaryResponse() != null && isConflictException(e)) {
|
||||
setResponse(item, item.getPrimaryResponse());
|
||||
} else {
|
||||
setResponse(item, new BulkItemResponse(item.id(), documentRequest.opType(),
|
||||
new BulkItemResponse.Failure(request.index(), documentRequest.type(), documentRequest.id(), e)));
|
||||
setResponse(item, new BulkItemResponse(item.id(), documentWriteRequest.opType(),
|
||||
new BulkItemResponse.Failure(request.index(), documentWriteRequest.type(), documentWriteRequest.id(), e)));
|
||||
}
|
||||
}
|
||||
assert request.items()[requestIndex].getPrimaryResponse() != null;
|
||||
|
@ -266,20 +254,20 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
|
|||
if (item == null || item.isIgnoreOnReplica()) {
|
||||
continue;
|
||||
}
|
||||
DocumentRequest documentRequest = (item.request() instanceof UpdateReplicaRequest)
|
||||
DocumentWriteRequest documentWriteRequest = (item.request() instanceof UpdateReplicaRequest)
|
||||
? ((UpdateReplicaRequest) item.request()).getRequest() : item.request();
|
||||
final Engine.Operation operation;
|
||||
try {
|
||||
switch (documentRequest.opType()) {
|
||||
switch (documentWriteRequest.opType()) {
|
||||
case CREATE:
|
||||
case INDEX:
|
||||
operation = TransportIndexAction.executeIndexRequestOnReplica(((IndexRequest) documentRequest), indexShard);
|
||||
operation = TransportIndexAction.executeIndexRequestOnReplica(((IndexRequest) documentWriteRequest), indexShard);
|
||||
break;
|
||||
case DELETE:
|
||||
operation = TransportDeleteAction.executeDeleteRequestOnReplica(((DeleteRequest) documentRequest), indexShard);
|
||||
operation = TransportDeleteAction.executeDeleteRequestOnReplica(((DeleteRequest) documentWriteRequest), indexShard);
|
||||
break;
|
||||
default: throw new IllegalStateException("Unexpected request operation type on replica: "
|
||||
+ documentRequest.opType().getLowercase());
|
||||
+ documentWriteRequest.opType().getLowercase());
|
||||
}
|
||||
location = locationToSync(location, operation.getTranslogLocation());
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
package org.elasticsearch.action.delete;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.DocumentRequest;
|
||||
import org.elasticsearch.action.support.replication.ReplicatedWriteRequest;
|
||||
import org.elasticsearch.action.DocumentWriteRequest;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
|
@ -43,7 +42,7 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|||
* @see org.elasticsearch.client.Client#delete(DeleteRequest)
|
||||
* @see org.elasticsearch.client.Requests#deleteRequest(String)
|
||||
*/
|
||||
public class DeleteRequest extends DocumentRequest<DeleteRequest> {
|
||||
public class DeleteRequest extends DocumentWriteRequest<DeleteRequest> {
|
||||
|
||||
private String type;
|
||||
private String id;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<IndexRequest> {
|
||||
public class IndexRequest extends DocumentWriteRequest<IndexRequest> {
|
||||
|
||||
private String type;
|
||||
private String id;
|
||||
|
|
|
@ -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<IndexRequest,
|
|||
/**
|
||||
* Sets the type of operation to perform.
|
||||
*/
|
||||
public IndexRequestBuilder setOpType(DocumentRequest.OpType opType) {
|
||||
public IndexRequestBuilder setOpType(DocumentWriteRequest.OpType opType) {
|
||||
request.opType(opType);
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.logging.log4j.util.Supplier;
|
|||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.DocumentRequest;
|
||||
import org.elasticsearch.action.DocumentWriteRequest;
|
||||
import org.elasticsearch.action.bulk.BulkAction;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
|
@ -135,7 +135,7 @@ public final class IngestActionFilter extends AbstractComponent implements Actio
|
|||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
static final class BulkRequestModifier implements Iterator<DocumentRequest<?>> {
|
||||
static final class BulkRequestModifier implements Iterator<DocumentWriteRequest<?>> {
|
||||
|
||||
final BulkRequest bulkRequest;
|
||||
final Set<Integer> 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;
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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<UpdateReplicaRequest> {
|
||||
private DocumentRequest<?> request;
|
||||
public class UpdateReplicaRequest extends DocumentWriteRequest<UpdateReplicaRequest> {
|
||||
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<UpdateReplicaRequest>
|
|||
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
|
||||
|
|
|
@ -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<UpdateRequest> {
|
||||
public class UpdateRequest extends DocumentWriteRequest<UpdateRequest> {
|
||||
|
||||
private String type;
|
||||
private String id;
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -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<DocumentRequest<?>> actionRequests,
|
||||
public void executeBulkRequest(Iterable<DocumentWriteRequest<?>> actionRequests,
|
||||
BiConsumer<IndexRequest, Exception> itemFailureHandler,
|
||||
Consumer<Exception> 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())) {
|
||||
|
|
|
@ -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<DocumentRequest<?>> requests = new ArrayList<>();
|
||||
List<DocumentWriteRequest<?>> 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"));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<BulkItemResponse> 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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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]"));
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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<Request extends Abstr
|
|||
}
|
||||
|
||||
/**
|
||||
* Wrapper for the {@link DocumentRequest} that are used in this action class.
|
||||
* Wrapper for the {@link DocumentWriteRequest} that are used in this action class.
|
||||
*/
|
||||
interface RequestWrapper<Self extends DocumentRequest<Self>> {
|
||||
interface RequestWrapper<Self extends DocumentWriteRequest<Self>> {
|
||||
|
||||
void setIndex(String index);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue