Enforce 140 char line lengths for packages action.bulk/delete/explain/get/index (#34885)
part of #34884
This commit is contained in:
parent
f5200e34ad
commit
11fa8d3744
|
@ -78,19 +78,6 @@
|
|||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]stats[/\\]TransportClusterStatsAction.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]tasks[/\\]PendingClusterTasksRequestBuilder.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]tasks[/\\]TransportPendingClusterTasksAction.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BackoffPolicy.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkProcessor.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkRequest.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkResponse.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]TransportBulkAction.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]TransportShardBulkAction.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]delete[/\\]DeleteRequest.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]explain[/\\]TransportExplainAction.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]GetRequest.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]MultiGetRequest.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]TransportGetAction.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]TransportShardMultiGetAction.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]index[/\\]IndexRequest.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]MultiSearchRequestBuilder.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchPhaseController.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]DelegatingActionListener.java" checks="LineLength" />
|
||||
|
@ -291,9 +278,6 @@
|
|||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]snapshots[/\\]SnapshotBlocksIT.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]state[/\\]ClusterStateRequestTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]admin[/\\]cluster[/\\]stats[/\\]ClusterStatsIT.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]BulkRequestTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]bulk[/\\]RetryTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]get[/\\]MultiGetShardRequestTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]search[/\\]SearchRequestBuilderTests.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]WaitActiveShardCountIT.java" checks="LineLength" />
|
||||
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]action[/\\]support[/\\]broadcast[/\\]node[/\\]TransportBroadcastByNodeActionTests.java" checks="LineLength" />
|
||||
|
|
|
@ -34,7 +34,8 @@ import java.util.NoSuchElementException;
|
|||
* semantics:
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>#hasNext()</code> determines whether the progression has more elements. Return <code>true</code> for infinite progressions</li>
|
||||
* <li><code>#hasNext()</code> determines whether the progression has more elements. Return <code>true</code> for infinite progressions
|
||||
* </li>
|
||||
* <li><code>#next()</code> determines the next element in the progression, i.e. the next wait time period</li>
|
||||
* </ul>
|
||||
*
|
||||
|
|
|
@ -217,12 +217,13 @@ public class BulkProcessor implements Closeable {
|
|||
* Closes the processor. If flushing by time is enabled, then it's shutdown. Any remaining bulk actions are flushed.
|
||||
* <p>
|
||||
* If concurrent requests are not enabled, returns {@code true} immediately.
|
||||
* If concurrent requests are enabled, waits for up to the specified timeout for all bulk requests to complete then returns {@code true},
|
||||
* If concurrent requests are enabled, waits for up to the specified timeout for all bulk requests to complete then returns {@code true}
|
||||
* If the specified waiting time elapses before all bulk requests complete, {@code false} is returned.
|
||||
*
|
||||
* @param timeout The maximum time to wait for the bulk requests to complete
|
||||
* @param unit The time unit of the {@code timeout} argument
|
||||
* @return {@code true} if all bulk requests completed and {@code false} if the waiting time elapsed before all the bulk requests completed
|
||||
* @return {@code true} if all bulk requests completed and {@code false} if the waiting time elapsed before all the bulk requests
|
||||
* completed
|
||||
* @throws InterruptedException If the current thread is interrupted
|
||||
*/
|
||||
public synchronized boolean awaitClose(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
|
@ -298,7 +299,8 @@ public class BulkProcessor implements Closeable {
|
|||
* Adds the data from the bytes to be processed by the bulk processor
|
||||
*/
|
||||
public synchronized BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType,
|
||||
@Nullable String defaultPipeline, @Nullable Object payload, XContentType xContentType) throws Exception {
|
||||
@Nullable String defaultPipeline, @Nullable Object payload,
|
||||
XContentType xContentType) throws Exception {
|
||||
bulkRequest.add(data, defaultIndex, defaultType, null, null, defaultPipeline, payload, true, xContentType);
|
||||
executeIfNeeded();
|
||||
return this;
|
||||
|
|
|
@ -369,20 +369,23 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
|||
} else if (SOURCE.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||
fetchSourceContext = FetchSourceContext.fromXContent(parser);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter [" + currentFieldName + "]");
|
||||
throw new IllegalArgumentException("Action/metadata line [" + line + "] contains an unknown parameter ["
|
||||
+ currentFieldName + "]");
|
||||
}
|
||||
} else if (token == XContentParser.Token.START_ARRAY) {
|
||||
throw new IllegalArgumentException("Malformed action/metadata line [" + line +
|
||||
"], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]");
|
||||
} else if (token == XContentParser.Token.START_OBJECT && SOURCE.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||
} else if (token == XContentParser.Token.START_OBJECT && SOURCE.match(currentFieldName,
|
||||
parser.getDeprecationHandler())) {
|
||||
fetchSourceContext = FetchSourceContext.fromXContent(parser);
|
||||
} else if (token != XContentParser.Token.VALUE_NULL) {
|
||||
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]");
|
||||
throw new IllegalArgumentException("Malformed action/metadata line [" + line
|
||||
+ "], expected a simple value for field [" + currentFieldName + "] but found [" + token + "]");
|
||||
}
|
||||
}
|
||||
} else if (token != XContentParser.Token.END_OBJECT) {
|
||||
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected " + XContentParser.Token.START_OBJECT
|
||||
+ " or " + XContentParser.Token.END_OBJECT + " but found [" + token + "]");
|
||||
throw new IllegalArgumentException("Malformed action/metadata line [" + line + "], expected "
|
||||
+ XContentParser.Token.START_OBJECT + " or " + XContentParser.Token.END_OBJECT + " but found [" + token + "]");
|
||||
}
|
||||
|
||||
if ("delete".equals(action)) {
|
||||
|
|
|
@ -109,7 +109,8 @@ public class BulkResponse extends ActionResponse implements Iterable<BulkItemRes
|
|||
BulkItemResponse response = responses[i];
|
||||
if (response.isFailed()) {
|
||||
sb.append("\n[").append(i)
|
||||
.append("]: index [").append(response.getIndex()).append("], type [").append(response.getType()).append("], id [").append(response.getId())
|
||||
.append("]: index [").append(response.getIndex()).append("], type [")
|
||||
.append(response.getType()).append("], id [").append(response.getId())
|
||||
.append("], message [").append(response.getFailureMessage()).append("]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -256,9 +256,11 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
client.admin().indices().create(createIndexRequest, listener);
|
||||
}
|
||||
|
||||
private boolean setResponseFailureIfIndexMatches(AtomicArray<BulkItemResponse> responses, int idx, DocWriteRequest<?> request, String index, Exception e) {
|
||||
private boolean setResponseFailureIfIndexMatches(AtomicArray<BulkItemResponse> responses, int idx, DocWriteRequest<?> 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)));
|
||||
responses.set(idx, new BulkItemResponse(idx, request.opType(), new BulkItemResponse.Failure(request.index(), request.type(),
|
||||
request.id(), e)));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -327,19 +329,22 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
indexRequest.process(indexCreated, mappingMd, concreteIndex.getName());
|
||||
break;
|
||||
case UPDATE:
|
||||
TransportUpdateAction.resolveAndValidateRouting(metaData, concreteIndex.getName(), (UpdateRequest) docWriteRequest);
|
||||
TransportUpdateAction.resolveAndValidateRouting(metaData, concreteIndex.getName(),
|
||||
(UpdateRequest) docWriteRequest);
|
||||
break;
|
||||
case DELETE:
|
||||
docWriteRequest.routing(metaData.resolveWriteIndexRouting(docWriteRequest.routing(), docWriteRequest.index()));
|
||||
// check if routing is required, if so, throw error if routing wasn't specified
|
||||
if (docWriteRequest.routing() == null && metaData.routingRequired(concreteIndex.getName(), docWriteRequest.type())) {
|
||||
if (docWriteRequest.routing() == null && metaData.routingRequired(concreteIndex.getName(),
|
||||
docWriteRequest.type())) {
|
||||
throw new RoutingMissingException(concreteIndex.getName(), docWriteRequest.type(), docWriteRequest.id());
|
||||
}
|
||||
break;
|
||||
default: throw new AssertionError("request type not supported: [" + docWriteRequest.opType() + "]");
|
||||
}
|
||||
} catch (ElasticsearchParseException | IllegalArgumentException | RoutingMissingException e) {
|
||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), docWriteRequest.type(), docWriteRequest.id(), e);
|
||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(concreteIndex.getName(), docWriteRequest.type(),
|
||||
docWriteRequest.id(), e);
|
||||
BulkItemResponse bulkItemResponse = new BulkItemResponse(i, docWriteRequest.opType(), failure);
|
||||
responses.set(i, bulkItemResponse);
|
||||
// make sure the request gets never processed again
|
||||
|
@ -355,13 +360,15 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
continue;
|
||||
}
|
||||
String concreteIndex = concreteIndices.getConcreteIndex(request.index()).getName();
|
||||
ShardId shardId = clusterService.operationRouting().indexShards(clusterState, concreteIndex, request.id(), request.routing()).shardId();
|
||||
ShardId shardId = clusterService.operationRouting().indexShards(clusterState, concreteIndex, request.id(),
|
||||
request.routing()).shardId();
|
||||
List<BulkItemRequest> shardRequests = requestsByShard.computeIfAbsent(shardId, shard -> new ArrayList<>());
|
||||
shardRequests.add(new BulkItemRequest(i, request));
|
||||
}
|
||||
|
||||
if (requestsByShard.isEmpty()) {
|
||||
listener.onResponse(new BulkResponse(responses.toArray(new BulkItemResponse[responses.length()]), buildTookInMillis(startTimeNanos)));
|
||||
listener.onResponse(new BulkResponse(responses.toArray(new BulkItemResponse[responses.length()]),
|
||||
buildTookInMillis(startTimeNanos)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -407,7 +414,8 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
}
|
||||
|
||||
private void finishHim() {
|
||||
listener.onResponse(new BulkResponse(responses.toArray(new BulkItemResponse[responses.length()]), buildTookInMillis(startTimeNanos)));
|
||||
listener.onResponse(new BulkResponse(responses.toArray(new BulkItemResponse[responses.length()]),
|
||||
buildTookInMillis(startTimeNanos)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -535,7 +543,8 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
} else {
|
||||
long ingestTookInMillis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - ingestStartTimeInNanos);
|
||||
BulkRequest bulkRequest = bulkRequestModifier.getBulkRequest();
|
||||
ActionListener<BulkResponse> actionListener = bulkRequestModifier.wrapActionListenerIfNeeded(ingestTookInMillis, listener);
|
||||
ActionListener<BulkResponse> actionListener = bulkRequestModifier.wrapActionListenerIfNeeded(ingestTookInMillis,
|
||||
listener);
|
||||
if (bulkRequest.requests().isEmpty()) {
|
||||
// at this stage, the transport bulk action can't deal with a bulk request with no requests,
|
||||
// so we stop and send an empty response back to the client.
|
||||
|
@ -628,7 +637,8 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
// 2) Add a bulk item failure for this request
|
||||
// 3) Continue with the next request in the bulk.
|
||||
failedSlots.set(currentSlot);
|
||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(indexRequest.index(), indexRequest.type(), indexRequest.id(), e);
|
||||
BulkItemResponse.Failure failure = new BulkItemResponse.Failure(indexRequest.index(), indexRequest.type(),
|
||||
indexRequest.id(), e);
|
||||
itemResponses.add(new BulkItemResponse(currentSlot, indexRequest.opType(), failure));
|
||||
}
|
||||
|
||||
|
@ -641,7 +651,8 @@ public class TransportBulkAction extends HandledTransportAction<BulkRequest, Bul
|
|||
private final List<BulkItemResponse> itemResponses;
|
||||
private final ActionListener<BulkResponse> actionListener;
|
||||
|
||||
IngestBulkResponseListener(long ingestTookInMillis, int[] originalSlots, List<BulkItemResponse> itemResponses, ActionListener<BulkResponse> actionListener) {
|
||||
IngestBulkResponseListener(long ingestTookInMillis, int[] originalSlots, List<BulkItemResponse> itemResponses,
|
||||
ActionListener<BulkResponse> actionListener) {
|
||||
this.ingestTookInMillis = ingestTookInMillis;
|
||||
this.itemResponses = itemResponses;
|
||||
this.actionListener = actionListener;
|
||||
|
|
|
@ -46,7 +46,8 @@ 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 ReplicatedWriteRequest<DeleteRequest> implements DocWriteRequest<DeleteRequest>, CompositeIndicesRequest {
|
||||
public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest>
|
||||
implements DocWriteRequest<DeleteRequest>, CompositeIndicesRequest {
|
||||
|
||||
private String type;
|
||||
private String id;
|
||||
|
@ -89,7 +90,8 @@ public class DeleteRequest extends ReplicatedWriteRequest<DeleteRequest> impleme
|
|||
validationException = addValidationError("id is missing", validationException);
|
||||
}
|
||||
if (!versionType.validateVersionForWrites(version)) {
|
||||
validationException = addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]", validationException);
|
||||
validationException = addValidationError("illegal version value [" + version + "] for version type ["
|
||||
+ versionType.name() + "]", validationException);
|
||||
}
|
||||
if (versionType == VersionType.FORCE) {
|
||||
validationException = addValidationError("version type [force] may no longer be used", validationException);
|
||||
|
|
|
@ -90,7 +90,8 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void asyncShardOperation(ExplainRequest request, ShardId shardId, ActionListener<ExplainResponse> listener) throws IOException {
|
||||
protected void asyncShardOperation(ExplainRequest request, ShardId shardId,
|
||||
ActionListener<ExplainResponse> listener) throws IOException {
|
||||
IndexService indexService = searchService.getIndicesService().indexServiceSafe(shardId.getIndex());
|
||||
IndexShard indexShard = indexService.getShard(shardId.id());
|
||||
indexShard.awaitShardSearchActive(b -> {
|
||||
|
@ -129,7 +130,8 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
|||
// Advantage is that we're not opening a second searcher to retrieve the _source. Also
|
||||
// because we are working in the same searcher in engineGetResult we can be sure that a
|
||||
// doc isn't deleted between the initial get and this call.
|
||||
GetResult getResult = context.indexShard().getService().get(result, request.id(), request.type(), request.storedFields(), request.fetchSourceContext());
|
||||
GetResult getResult = context.indexShard().getService().get(result, request.id(), request.type(), request.storedFields(),
|
||||
request.fetchSourceContext());
|
||||
return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), true, explanation, getResult);
|
||||
} else {
|
||||
return new ExplainResponse(shardId.getIndexName(), request.type(), request.id(), true, explanation);
|
||||
|
@ -149,7 +151,8 @@ public class TransportExplainAction extends TransportSingleShardAction<ExplainRe
|
|||
@Override
|
||||
protected ShardIterator shards(ClusterState state, InternalRequest request) {
|
||||
return clusterService.operationRouting().getShards(
|
||||
clusterService.state(), request.concreteIndex(), request.request().id(), request.request().routing(), request.request().preference()
|
||||
clusterService.state(), request.concreteIndex(), request.request().id(), request.request().routing(),
|
||||
request.request().preference()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,8 +98,8 @@ public class GetRequest extends SingleShardRequest<GetRequest> implements Realti
|
|||
validationException = ValidateActions.addValidationError("id is missing", validationException);
|
||||
}
|
||||
if (!versionType.validateVersionForReads(version)) {
|
||||
validationException = ValidateActions.addValidationError("illegal version value [" + version + "] for version type [" + versionType.name() + "]",
|
||||
validationException);
|
||||
validationException = ValidateActions.addValidationError("illegal version value [" + version + "] for version type ["
|
||||
+ versionType.name() + "]", validationException);
|
||||
}
|
||||
if (versionType == VersionType.FORCE) {
|
||||
validationException = ValidateActions.addValidationError("version type [force] may no longer be used", validationException);
|
||||
|
|
|
@ -360,7 +360,8 @@ public class MultiGetRequest extends ActionRequest
|
|||
currentFieldName = parser.currentName();
|
||||
} else if (token == Token.START_ARRAY) {
|
||||
if ("docs".equals(currentFieldName)) {
|
||||
parseDocuments(parser, this.items, defaultIndex, defaultType, defaultFields, defaultFetchSource, defaultRouting, allowExplicitIndex);
|
||||
parseDocuments(parser, this.items, defaultIndex, defaultType, defaultFields, defaultFetchSource, defaultRouting,
|
||||
allowExplicitIndex);
|
||||
} else if ("ids".equals(currentFieldName)) {
|
||||
parseIds(parser, this.items, defaultIndex, defaultType, defaultFields, defaultFetchSource, defaultRouting);
|
||||
} else {
|
||||
|
@ -384,7 +385,9 @@ public class MultiGetRequest extends ActionRequest
|
|||
return this;
|
||||
}
|
||||
|
||||
private static void parseDocuments(XContentParser parser, List<Item> items, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting, boolean allowExplicitIndex) throws IOException {
|
||||
private static void parseDocuments(XContentParser parser, List<Item> items, @Nullable String defaultIndex, @Nullable String defaultType,
|
||||
@Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource,
|
||||
@Nullable String defaultRouting, boolean allowExplicitIndex) throws IOException {
|
||||
String currentFieldName = null;
|
||||
Token token;
|
||||
while ((token = parser.nextToken()) != Token.END_ARRAY) {
|
||||
|
@ -499,13 +502,16 @@ public class MultiGetRequest extends ActionRequest
|
|||
}
|
||||
}
|
||||
|
||||
public static void parseIds(XContentParser parser, List<Item> items, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource, @Nullable String defaultRouting) throws IOException {
|
||||
public static void parseIds(XContentParser parser, List<Item> items, @Nullable String defaultIndex, @Nullable String defaultType,
|
||||
@Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSource,
|
||||
@Nullable String defaultRouting) throws IOException {
|
||||
Token token;
|
||||
while ((token = parser.nextToken()) != Token.END_ARRAY) {
|
||||
if (!token.isValue()) {
|
||||
throw new IllegalArgumentException("ids array element should only contain ids");
|
||||
}
|
||||
items.add(new Item(defaultIndex, defaultType, parser.text()).storedFields(defaultFields).fetchSourceContext(defaultFetchSource).routing(defaultRouting));
|
||||
items.add(new Item(defaultIndex, defaultType, parser.text()).storedFields(defaultFields).fetchSourceContext(defaultFetchSource)
|
||||
.routing(defaultRouting));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,8 @@ public class TransportGetAction extends TransportSingleShardAction<GetRequest, G
|
|||
@Override
|
||||
protected ShardIterator shards(ClusterState state, InternalRequest request) {
|
||||
return clusterService.operationRouting()
|
||||
.getShards(clusterService.state(), request.concreteIndex(), request.request().id(), request.request().routing(), request.request().preference());
|
||||
.getShards(clusterService.state(), request.concreteIndex(), request.request().id(), request.request().routing(),
|
||||
request.request().preference());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -86,8 +86,8 @@ public class TransportShardMultiGetAction extends TransportSingleShardAction<Mul
|
|||
for (int i = 0; i < request.locations.size(); i++) {
|
||||
MultiGetRequest.Item item = request.items.get(i);
|
||||
try {
|
||||
GetResult getResult = indexShard.getService().get(item.type(), item.id(), item.storedFields(), request.realtime(), item.version(),
|
||||
item.versionType(), item.fetchSourceContext());
|
||||
GetResult getResult = indexShard.getService().get(item.type(), item.id(), item.storedFields(), request.realtime(),
|
||||
item.version(), item.versionType(), item.fetchSourceContext());
|
||||
response.add(request.locations.get(i), new GetResponse(getResult));
|
||||
} catch (RuntimeException e) {
|
||||
if (TransportActions.isShardNotAvailableException(e)) {
|
||||
|
|
|
@ -154,12 +154,14 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
final long resolvedVersion = resolveVersionDefaults();
|
||||
if (opType() == OpType.CREATE) {
|
||||
if (versionType != VersionType.INTERNAL) {
|
||||
validationException = addValidationError("create operations only support internal versioning. use index instead", validationException);
|
||||
validationException = addValidationError("create operations only support internal versioning. use index instead",
|
||||
validationException);
|
||||
return validationException;
|
||||
}
|
||||
|
||||
if (resolvedVersion != Versions.MATCH_DELETED) {
|
||||
validationException = addValidationError("create operations do not support explicit versions. use index instead", validationException);
|
||||
validationException = addValidationError("create operations do not support explicit versions. use index instead",
|
||||
validationException);
|
||||
return validationException;
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +171,8 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
}
|
||||
|
||||
if (!versionType.validateVersionForWrites(resolvedVersion)) {
|
||||
validationException = addValidationError("illegal version value [" + resolvedVersion + "] for version type [" + versionType.name() + "]", validationException);
|
||||
validationException = addValidationError("illegal version value [" + resolvedVersion + "] for version type ["
|
||||
+ versionType.name() + "]", validationException);
|
||||
}
|
||||
|
||||
if (versionType == VersionType.FORCE) {
|
||||
|
@ -347,7 +350,8 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
throw new IllegalArgumentException("The number of object passed must be even but was [" + source.length + "]");
|
||||
}
|
||||
if (source.length == 2 && source[0] instanceof BytesReference && source[1] instanceof Boolean) {
|
||||
throw new IllegalArgumentException("you are using the removed method for source with bytes and unsafe flag, the unsafe flag was removed, please just use source(BytesReference)");
|
||||
throw new IllegalArgumentException("you are using the removed method for source with bytes and unsafe flag, the unsafe flag"
|
||||
+ " was removed, please just use source(BytesReference)");
|
||||
}
|
||||
try {
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(xContentType);
|
||||
|
|
|
@ -165,7 +165,8 @@ public class BulkRequestTests extends ESTestCase {
|
|||
BulkRequest bulkRequest = new BulkRequest();
|
||||
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class,
|
||||
() -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, null, XContentType.JSON));
|
||||
assertThat(exc.getMessage(), containsString("Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [START_ARRAY]"));
|
||||
assertThat(exc.getMessage(),
|
||||
containsString("Malformed action/metadata line [3], expected START_OBJECT or END_OBJECT but found [START_ARRAY]"));
|
||||
}
|
||||
|
||||
public void testSimpleBulk10() throws Exception {
|
||||
|
@ -207,7 +208,8 @@ public class BulkRequestTests extends ESTestCase {
|
|||
BulkRequest bulkRequest = new BulkRequest();
|
||||
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class,
|
||||
() -> bulkRequest.add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, null, XContentType.JSON));
|
||||
assertThat(exc.getMessage(), containsString("Malformed action/metadata line [" + emptyLine + "], expected FIELD_NAME but found [END_OBJECT]"));
|
||||
assertThat(exc.getMessage(), containsString("Malformed action/metadata line ["
|
||||
+ emptyLine + "], expected FIELD_NAME but found [END_OBJECT]"));
|
||||
}
|
||||
|
||||
// issue 7361
|
||||
|
|
|
@ -230,7 +230,8 @@ public class RetryTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private BulkItemResponse failedResponse() {
|
||||
return new BulkItemResponse(1, OpType.INDEX, new BulkItemResponse.Failure("test", "test", "1", new EsRejectedExecutionException("pool full")));
|
||||
return new BulkItemResponse(1, OpType.INDEX, new BulkItemResponse.Failure("test", "test", "1",
|
||||
new EsRejectedExecutionException("pool full")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ public class MultiGetShardRequestTests extends ESTestCase {
|
|||
MultiGetShardRequest multiGetShardRequest = new MultiGetShardRequest(multiGetRequest, "index", 0);
|
||||
int numItems = iterations(10, 30);
|
||||
for (int i = 0; i < numItems; i++) {
|
||||
MultiGetRequest.Item item = new MultiGetRequest.Item("alias-" + randomAlphaOfLength(randomIntBetween(1, 10)), "type", "id-" + i);
|
||||
MultiGetRequest.Item item = new MultiGetRequest.Item("alias-" + randomAlphaOfLength(randomIntBetween(1, 10)),
|
||||
"type", "id-" + i);
|
||||
if (randomBoolean()) {
|
||||
int numFields = randomIntBetween(1, 5);
|
||||
String[] fields = new String[numFields];
|
||||
|
|
Loading…
Reference in New Issue