Switch WritePipelineResponse to AcknowledgedResponse (#32722)
We previously discussed moving the classes extending `AcknowledgedResponse` to simply use `AcknowledgedResponse`, making the class non-abstract. This moves the first class to do this, removing `WritePipelineResponse` in the process. If we like the way this looks, I will switch the remaining classes over to using `AcknowledgedResponse`.
This commit is contained in:
parent
d586e4cfd3
commit
7af28c48c3
|
@ -26,7 +26,7 @@ import org.elasticsearch.action.ingest.GetPipelineResponse;
|
|||
import org.elasticsearch.action.ingest.PutPipelineRequest;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -54,9 +54,9 @@ public final class IngestClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public WritePipelineResponse putPipeline(PutPipelineRequest request, RequestOptions options) throws IOException {
|
||||
public AcknowledgedResponse putPipeline(PutPipelineRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::putPipeline, options,
|
||||
WritePipelineResponse::fromXContent, emptySet());
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,9 +67,9 @@ public final class IngestClient {
|
|||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
|
||||
* @param listener the listener to be notified upon request completion
|
||||
*/
|
||||
public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener<WritePipelineResponse> listener) {
|
||||
public void putPipelineAsync(PutPipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::putPipeline, options,
|
||||
WritePipelineResponse::fromXContent, listener, emptySet());
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,9 +109,9 @@ public final class IngestClient {
|
|||
* @return the response
|
||||
* @throws IOException in case there is a problem sending the request or parsing back the response
|
||||
*/
|
||||
public WritePipelineResponse deletePipeline(DeletePipelineRequest request, RequestOptions options) throws IOException {
|
||||
public AcknowledgedResponse deletePipeline(DeletePipelineRequest request, RequestOptions options) throws IOException {
|
||||
return restHighLevelClient.performRequestAndParseEntity( request, RequestConverters::deletePipeline, options,
|
||||
WritePipelineResponse::fromXContent, emptySet());
|
||||
AcknowledgedResponse::fromXContent, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,9 +123,9 @@ public final class IngestClient {
|
|||
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
|
||||
* @param listener the listener to be notified upon request completion
|
||||
*/
|
||||
public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener<WritePipelineResponse> listener) {
|
||||
public void deletePipelineAsync(DeletePipelineRequest request, RequestOptions options, ActionListener<AcknowledgedResponse> listener) {
|
||||
restHighLevelClient.performRequestAsyncAndParseEntity( request, RequestConverters::deletePipeline, options,
|
||||
WritePipelineResponse::fromXContent, listener, emptySet());
|
||||
AcknowledgedResponse::fromXContent, listener, emptySet());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.action.ingest.SimulateDocumentResult;
|
|||
import org.elasticsearch.action.ingest.SimulateDocumentVerboseResult;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
|
@ -50,7 +50,7 @@ public class IngestClientIT extends ESRestHighLevelClientTestCase {
|
|||
BytesReference.bytes(pipelineBuilder),
|
||||
pipelineBuilder.contentType());
|
||||
|
||||
WritePipelineResponse putPipelineResponse =
|
||||
AcknowledgedResponse putPipelineResponse =
|
||||
execute(request, highLevelClient().ingest()::putPipeline, highLevelClient().ingest()::putPipelineAsync);
|
||||
assertTrue(putPipelineResponse.isAcknowledged());
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public class IngestClientIT extends ESRestHighLevelClientTestCase {
|
|||
|
||||
DeletePipelineRequest request = new DeletePipelineRequest(id);
|
||||
|
||||
WritePipelineResponse response =
|
||||
AcknowledgedResponse response =
|
||||
execute(request, highLevelClient().ingest()::deletePipeline, highLevelClient().ingest()::deletePipelineAsync);
|
||||
assertTrue(response.isAcknowledged());
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.elasticsearch.action.ingest.SimulateDocumentVerboseResult;
|
|||
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
|
||||
import org.elasticsearch.action.ingest.SimulateProcessorResult;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.ESRestHighLevelClientTestCase;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
|
@ -93,7 +93,7 @@ public class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// end::put-pipeline-request-masterTimeout
|
||||
|
||||
// tag::put-pipeline-execute
|
||||
WritePipelineResponse response = client.ingest().putPipeline(request, RequestOptions.DEFAULT); // <1>
|
||||
AcknowledgedResponse response = client.ingest().putPipeline(request, RequestOptions.DEFAULT); // <1>
|
||||
// end::put-pipeline-execute
|
||||
|
||||
// tag::put-pipeline-response
|
||||
|
@ -117,10 +117,10 @@ public class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
);
|
||||
|
||||
// tag::put-pipeline-execute-listener
|
||||
ActionListener<WritePipelineResponse> listener =
|
||||
new ActionListener<WritePipelineResponse>() {
|
||||
ActionListener<AcknowledgedResponse> listener =
|
||||
new ActionListener<AcknowledgedResponse>() {
|
||||
@Override
|
||||
public void onResponse(WritePipelineResponse response) {
|
||||
public void onResponse(AcknowledgedResponse response) {
|
||||
// <1>
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ public class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
// end::delete-pipeline-request-masterTimeout
|
||||
|
||||
// tag::delete-pipeline-execute
|
||||
WritePipelineResponse response = client.ingest().deletePipeline(request, RequestOptions.DEFAULT); // <1>
|
||||
AcknowledgedResponse response = client.ingest().deletePipeline(request, RequestOptions.DEFAULT); // <1>
|
||||
// end::delete-pipeline-execute
|
||||
|
||||
// tag::delete-pipeline-response
|
||||
|
@ -257,10 +257,10 @@ public class IngestClientDocumentationIT extends ESRestHighLevelClientTestCase {
|
|||
DeletePipelineRequest request = new DeletePipelineRequest("my-pipeline-id");
|
||||
|
||||
// tag::delete-pipeline-execute-listener
|
||||
ActionListener<WritePipelineResponse> listener =
|
||||
new ActionListener<WritePipelineResponse>() {
|
||||
ActionListener<AcknowledgedResponse> listener =
|
||||
new ActionListener<AcknowledgedResponse>() {
|
||||
@Override
|
||||
public void onResponse(WritePipelineResponse response) {
|
||||
public void onResponse(AcknowledgedResponse response) {
|
||||
// <1>
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.action.ingest;
|
||||
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
|
||||
public class DeletePipelineAction extends Action<WritePipelineResponse> {
|
||||
public class DeletePipelineAction extends Action<AcknowledgedResponse> {
|
||||
|
||||
public static final DeletePipelineAction INSTANCE = new DeletePipelineAction();
|
||||
public static final String NAME = "cluster:admin/ingest/pipeline/delete";
|
||||
|
@ -31,7 +32,7 @@ public class DeletePipelineAction extends Action<WritePipelineResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WritePipelineResponse newResponse() {
|
||||
return new WritePipelineResponse();
|
||||
public AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@
|
|||
package org.elasticsearch.action.ingest;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
|
||||
public class DeletePipelineRequestBuilder extends ActionRequestBuilder<DeletePipelineRequest, WritePipelineResponse> {
|
||||
public class DeletePipelineRequestBuilder extends ActionRequestBuilder<DeletePipelineRequest, AcknowledgedResponse> {
|
||||
|
||||
public DeletePipelineRequestBuilder(ElasticsearchClient client, DeletePipelineAction action) {
|
||||
super(client, action, new DeletePipelineRequest());
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.action.ingest;
|
|||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
|
@ -34,7 +35,7 @@ import org.elasticsearch.node.NodeService;
|
|||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
||||
public class DeletePipelineTransportAction extends TransportMasterNodeAction<DeletePipelineRequest, WritePipelineResponse> {
|
||||
public class DeletePipelineTransportAction extends TransportMasterNodeAction<DeletePipelineRequest, AcknowledgedResponse> {
|
||||
|
||||
private final PipelineStore pipelineStore;
|
||||
private final ClusterService clusterService;
|
||||
|
@ -54,12 +55,12 @@ public class DeletePipelineTransportAction extends TransportMasterNodeAction<Del
|
|||
}
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse newResponse() {
|
||||
return new WritePipelineResponse();
|
||||
protected AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(DeletePipelineRequest request, ClusterState state, ActionListener<WritePipelineResponse> listener) throws Exception {
|
||||
protected void masterOperation(DeletePipelineRequest request, ClusterState state, ActionListener<AcknowledgedResponse> listener) throws Exception {
|
||||
pipelineStore.delete(clusterService, request, listener);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
package org.elasticsearch.action.ingest;
|
||||
|
||||
import org.elasticsearch.action.Action;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
|
||||
public class PutPipelineAction extends Action<WritePipelineResponse> {
|
||||
public class PutPipelineAction extends Action<AcknowledgedResponse> {
|
||||
|
||||
public static final PutPipelineAction INSTANCE = new PutPipelineAction();
|
||||
public static final String NAME = "cluster:admin/ingest/pipeline/put";
|
||||
|
@ -31,7 +32,7 @@ public class PutPipelineAction extends Action<WritePipelineResponse> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WritePipelineResponse newResponse() {
|
||||
return new WritePipelineResponse();
|
||||
public AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
package org.elasticsearch.action.ingest;
|
||||
|
||||
import org.elasticsearch.action.ActionRequestBuilder;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.ElasticsearchClient;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
|
||||
public class PutPipelineRequestBuilder extends ActionRequestBuilder<PutPipelineRequest, WritePipelineResponse> {
|
||||
public class PutPipelineRequestBuilder extends ActionRequestBuilder<PutPipelineRequest, AcknowledgedResponse> {
|
||||
|
||||
public PutPipelineRequestBuilder(ElasticsearchClient client, PutPipelineAction action) {
|
||||
super(client, action, new PutPipelineRequest());
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
|||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -43,7 +44,7 @@ import org.elasticsearch.transport.TransportService;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PutPipelineTransportAction extends TransportMasterNodeAction<PutPipelineRequest, WritePipelineResponse> {
|
||||
public class PutPipelineTransportAction extends TransportMasterNodeAction<PutPipelineRequest, AcknowledgedResponse> {
|
||||
|
||||
private final PipelineStore pipelineStore;
|
||||
private final ClusterService clusterService;
|
||||
|
@ -66,12 +67,12 @@ public class PutPipelineTransportAction extends TransportMasterNodeAction<PutPip
|
|||
}
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse newResponse() {
|
||||
return new WritePipelineResponse();
|
||||
protected AcknowledgedResponse newResponse() {
|
||||
return new AcknowledgedResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void masterOperation(PutPipelineRequest request, ClusterState state, ActionListener<WritePipelineResponse> listener) throws Exception {
|
||||
protected void masterOperation(PutPipelineRequest request, ClusterState state, ActionListener<AcknowledgedResponse> listener) throws Exception {
|
||||
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
|
||||
nodesInfoRequest.clear();
|
||||
nodesInfoRequest.ingest(true);
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.ingest;
|
||||
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
||||
public class WritePipelineResponse extends AcknowledgedResponse implements ToXContentObject {
|
||||
|
||||
WritePipelineResponse() {
|
||||
}
|
||||
|
||||
public WritePipelineResponse(boolean acknowledged) {
|
||||
super(acknowledged);
|
||||
}
|
||||
|
||||
public static WritePipelineResponse fromXContent(XContentParser parser) {
|
||||
return new WritePipelineResponse(parseAcknowledged(parser));
|
||||
}
|
||||
}
|
|
@ -34,10 +34,9 @@ import java.util.Objects;
|
|||
import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg;
|
||||
|
||||
/**
|
||||
* Abstract class that allows to mark action responses that support acknowledgements.
|
||||
* Facilitates consistency across different api.
|
||||
* A response that indicates that a request has been acknowledged
|
||||
*/
|
||||
public abstract class AcknowledgedResponse extends ActionResponse implements ToXContentObject {
|
||||
public class AcknowledgedResponse extends ActionResponse implements ToXContentObject {
|
||||
|
||||
private static final ParseField ACKNOWLEDGED = new ParseField("acknowledged");
|
||||
|
||||
|
@ -48,11 +47,10 @@ public abstract class AcknowledgedResponse extends ActionResponse implements ToX
|
|||
|
||||
protected boolean acknowledged;
|
||||
|
||||
protected AcknowledgedResponse() {
|
||||
|
||||
public AcknowledgedResponse() {
|
||||
}
|
||||
|
||||
protected AcknowledgedResponse(boolean acknowledged) {
|
||||
public AcknowledgedResponse(boolean acknowledged) {
|
||||
this.acknowledged = acknowledged;
|
||||
}
|
||||
|
||||
|
@ -100,10 +98,15 @@ public abstract class AcknowledgedResponse extends ActionResponse implements ToX
|
|||
ObjectParser.ValueType.BOOLEAN);
|
||||
}
|
||||
|
||||
protected static boolean parseAcknowledged(XContentParser parser) {
|
||||
@Deprecated
|
||||
public static boolean parseAcknowledged(XContentParser parser) {
|
||||
return ACKNOWLEDGED_FLAG_PARSER.apply(parser, null);
|
||||
}
|
||||
|
||||
public static AcknowledgedResponse fromXContent(XContentParser parser) throws IOException {
|
||||
return new AcknowledgedResponse(ACKNOWLEDGED_FLAG_PARSER.apply(parser, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
|
|
@ -113,7 +113,7 @@ import org.elasticsearch.action.ingest.PutPipelineRequestBuilder;
|
|||
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineRequestBuilder;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.tasks.TaskId;
|
||||
|
@ -574,12 +574,12 @@ public interface ClusterAdminClient extends ElasticsearchClient {
|
|||
/**
|
||||
* Stores an ingest pipeline
|
||||
*/
|
||||
void putPipeline(PutPipelineRequest request, ActionListener<WritePipelineResponse> listener);
|
||||
void putPipeline(PutPipelineRequest request, ActionListener<AcknowledgedResponse> listener);
|
||||
|
||||
/**
|
||||
* Stores an ingest pipeline
|
||||
*/
|
||||
ActionFuture<WritePipelineResponse> putPipeline(PutPipelineRequest request);
|
||||
ActionFuture<AcknowledgedResponse> putPipeline(PutPipelineRequest request);
|
||||
|
||||
/**
|
||||
* Stores an ingest pipeline
|
||||
|
@ -596,12 +596,12 @@ public interface ClusterAdminClient extends ElasticsearchClient {
|
|||
/**
|
||||
* Deletes a stored ingest pipeline
|
||||
*/
|
||||
void deletePipeline(DeletePipelineRequest request, ActionListener<WritePipelineResponse> listener);
|
||||
void deletePipeline(DeletePipelineRequest request, ActionListener<AcknowledgedResponse> listener);
|
||||
|
||||
/**
|
||||
* Deletes a stored ingest pipeline
|
||||
*/
|
||||
ActionFuture<WritePipelineResponse> deletePipeline(DeletePipelineRequest request);
|
||||
ActionFuture<AcknowledgedResponse> deletePipeline(DeletePipelineRequest request);
|
||||
|
||||
/**
|
||||
* Deletes a stored ingest pipeline
|
||||
|
|
|
@ -307,7 +307,6 @@ import org.elasticsearch.action.ingest.SimulatePipelineAction;
|
|||
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineRequestBuilder;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.search.ClearScrollAction;
|
||||
import org.elasticsearch.action.search.ClearScrollRequest;
|
||||
import org.elasticsearch.action.search.ClearScrollRequestBuilder;
|
||||
|
@ -325,6 +324,7 @@ import org.elasticsearch.action.search.SearchScrollRequest;
|
|||
import org.elasticsearch.action.search.SearchScrollRequestBuilder;
|
||||
import org.elasticsearch.action.support.PlainActionFuture;
|
||||
import org.elasticsearch.action.support.ThreadedActionListener;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.termvectors.MultiTermVectorsAction;
|
||||
import org.elasticsearch.action.termvectors.MultiTermVectorsRequest;
|
||||
import org.elasticsearch.action.termvectors.MultiTermVectorsRequestBuilder;
|
||||
|
@ -1082,12 +1082,12 @@ public abstract class AbstractClient extends AbstractComponent implements Client
|
|||
}
|
||||
|
||||
@Override
|
||||
public void putPipeline(PutPipelineRequest request, ActionListener<WritePipelineResponse> listener) {
|
||||
public void putPipeline(PutPipelineRequest request, ActionListener<AcknowledgedResponse> listener) {
|
||||
execute(PutPipelineAction.INSTANCE, request, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionFuture<WritePipelineResponse> putPipeline(PutPipelineRequest request) {
|
||||
public ActionFuture<AcknowledgedResponse> putPipeline(PutPipelineRequest request) {
|
||||
return execute(PutPipelineAction.INSTANCE, request);
|
||||
}
|
||||
|
||||
|
@ -1102,12 +1102,12 @@ public abstract class AbstractClient extends AbstractComponent implements Client
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deletePipeline(DeletePipelineRequest request, ActionListener<WritePipelineResponse> listener) {
|
||||
public void deletePipeline(DeletePipelineRequest request, ActionListener<AcknowledgedResponse> listener) {
|
||||
execute(DeletePipelineAction.INSTANCE, request, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionFuture<WritePipelineResponse> deletePipeline(DeletePipelineRequest request) {
|
||||
public ActionFuture<AcknowledgedResponse> deletePipeline(DeletePipelineRequest request) {
|
||||
return execute(DeletePipelineAction.INSTANCE, request);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.elasticsearch.ResourceNotFoundException;
|
|||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ingest.DeletePipelineRequest;
|
||||
import org.elasticsearch.action.ingest.PutPipelineRequest;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
|
||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
|
@ -121,13 +121,13 @@ public class PipelineStore extends AbstractComponent implements ClusterStateAppl
|
|||
/**
|
||||
* Deletes the pipeline specified by id in the request.
|
||||
*/
|
||||
public void delete(ClusterService clusterService, DeletePipelineRequest request, ActionListener<WritePipelineResponse> listener) {
|
||||
public void delete(ClusterService clusterService, DeletePipelineRequest request, ActionListener<AcknowledgedResponse> listener) {
|
||||
clusterService.submitStateUpdateTask("delete-pipeline-" + request.getId(),
|
||||
new AckedClusterStateUpdateTask<WritePipelineResponse>(request, listener) {
|
||||
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse newResponse(boolean acknowledged) {
|
||||
return new WritePipelineResponse(acknowledged);
|
||||
protected AcknowledgedResponse newResponse(boolean acknowledged) {
|
||||
return new AcknowledgedResponse(acknowledged);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,15 +169,15 @@ public class PipelineStore extends AbstractComponent implements ClusterStateAppl
|
|||
* Stores the specified pipeline definition in the request.
|
||||
*/
|
||||
public void put(ClusterService clusterService, Map<DiscoveryNode, IngestInfo> ingestInfos, PutPipelineRequest request,
|
||||
ActionListener<WritePipelineResponse> listener) throws Exception {
|
||||
ActionListener<AcknowledgedResponse> listener) throws Exception {
|
||||
// validates the pipeline and processor configuration before submitting a cluster update task:
|
||||
validatePipeline(ingestInfos, request);
|
||||
clusterService.submitStateUpdateTask("put-pipeline-" + request.getId(),
|
||||
new AckedClusterStateUpdateTask<WritePipelineResponse>(request, listener) {
|
||||
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse newResponse(boolean acknowledged) {
|
||||
return new WritePipelineResponse(acknowledged);
|
||||
protected AcknowledgedResponse newResponse(boolean acknowledged) {
|
||||
return new AcknowledgedResponse(acknowledged);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.action.ingest;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.test.AbstractStreamableXContentTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
|
||||
public class WritePipelineResponseTests extends AbstractStreamableXContentTestCase<WritePipelineResponse> {
|
||||
|
||||
public void testSerializationWithoutError() throws IOException {
|
||||
boolean isAcknowledged = randomBoolean();
|
||||
WritePipelineResponse response;
|
||||
response = new WritePipelineResponse(isAcknowledged);
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
response.writeTo(out);
|
||||
StreamInput streamInput = out.bytes().streamInput();
|
||||
WritePipelineResponse otherResponse = new WritePipelineResponse();
|
||||
otherResponse.readFrom(streamInput);
|
||||
|
||||
assertThat(otherResponse.isAcknowledged(), equalTo(response.isAcknowledged()));
|
||||
}
|
||||
|
||||
public void testSerializationWithError() throws IOException {
|
||||
WritePipelineResponse response = new WritePipelineResponse();
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
response.writeTo(out);
|
||||
StreamInput streamInput = out.bytes().streamInput();
|
||||
WritePipelineResponse otherResponse = new WritePipelineResponse();
|
||||
otherResponse.readFrom(streamInput);
|
||||
|
||||
assertThat(otherResponse.isAcknowledged(), equalTo(response.isAcknowledged()));
|
||||
}
|
||||
|
||||
public void testToXContent() {
|
||||
WritePipelineResponse response = new WritePipelineResponse(true);
|
||||
String output = Strings.toString(response);
|
||||
assertEquals("{\"acknowledged\":true}", output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse doParseInstance(XContentParser parser) {
|
||||
return WritePipelineResponse.fromXContent(parser);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse createTestInstance() {
|
||||
return new WritePipelineResponse(randomBoolean());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse createBlankInstance() {
|
||||
return new WritePipelineResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WritePipelineResponse mutateInstance(WritePipelineResponse response) {
|
||||
return new WritePipelineResponse(response.isAcknowledged() == false);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ import org.elasticsearch.action.ingest.PutPipelineRequest;
|
|||
import org.elasticsearch.action.ingest.SimulateDocumentBaseResult;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineRequest;
|
||||
import org.elasticsearch.action.ingest.SimulatePipelineResponse;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.client.Requests;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -126,7 +126,7 @@ public class IngestClientIT extends ESIntegTestCase {
|
|||
assertThat(simulateDocumentBaseResult.getFailure(), nullValue());
|
||||
|
||||
// cleanup
|
||||
WritePipelineResponse deletePipelineResponse = client().admin().cluster().prepareDeletePipeline("_id").get();
|
||||
AcknowledgedResponse deletePipelineResponse = client().admin().cluster().prepareDeletePipeline("_id").get();
|
||||
assertTrue(deletePipelineResponse.isAcknowledged());
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class IngestClientIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
// cleanup
|
||||
WritePipelineResponse deletePipelineResponse = client().admin().cluster().prepareDeletePipeline("_id").get();
|
||||
AcknowledgedResponse deletePipelineResponse = client().admin().cluster().prepareDeletePipeline("_id").get();
|
||||
assertTrue(deletePipelineResponse.isAcknowledged());
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ public class IngestClientIT extends ESIntegTestCase {
|
|||
assertThat(doc.get("processed"), equalTo(true));
|
||||
|
||||
DeletePipelineRequest deletePipelineRequest = new DeletePipelineRequest("_id");
|
||||
WritePipelineResponse response = client().admin().cluster().deletePipeline(deletePipelineRequest).get();
|
||||
AcknowledgedResponse response = client().admin().cluster().deletePipeline(deletePipelineRequest).get();
|
||||
assertThat(response.isAcknowledged(), is(true));
|
||||
|
||||
getResponse = client().admin().cluster().prepareGetPipeline("_id").get();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
package org.elasticsearch.ingest;
|
||||
|
||||
import org.elasticsearch.ElasticsearchParseException;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.node.NodeService;
|
||||
|
@ -95,7 +95,7 @@ public class IngestProcessorNotInstalledOnAllNodesIT extends ESIntegTestCase {
|
|||
installPlugin = true;
|
||||
String node1 = internalCluster().startNode();
|
||||
|
||||
WritePipelineResponse response = client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get();
|
||||
AcknowledgedResponse response = client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get();
|
||||
assertThat(response.isAcknowledged(), is(true));
|
||||
Pipeline pipeline = internalCluster().getInstance(NodeService.class, node1).getIngestService().getPipelineStore().get("_id");
|
||||
assertThat(pipeline, notNullValue());
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
|
|||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
|
||||
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
|
||||
import org.elasticsearch.action.ingest.PutPipelineRequest;
|
||||
import org.elasticsearch.action.ingest.WritePipelineResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||
|
@ -39,6 +38,7 @@ import org.elasticsearch.index.IndexNotFoundException;
|
|||
import org.elasticsearch.ingest.IngestMetadata;
|
||||
import org.elasticsearch.ingest.PipelineConfiguration;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
|
||||
import org.elasticsearch.protocol.xpack.watcher.PutWatchResponse;
|
||||
import org.elasticsearch.xpack.core.XPackClient;
|
||||
|
@ -46,7 +46,6 @@ import org.elasticsearch.xpack.core.XPackSettings;
|
|||
import org.elasticsearch.xpack.core.monitoring.MonitoredSystem;
|
||||
import org.elasticsearch.xpack.core.monitoring.exporter.MonitoringTemplateUtils;
|
||||
import org.elasticsearch.xpack.core.watcher.client.WatcherClient;
|
||||
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
|
||||
import org.elasticsearch.xpack.core.watcher.transport.actions.get.GetWatchRequest;
|
||||
import org.elasticsearch.xpack.core.watcher.transport.actions.get.GetWatchResponse;
|
||||
import org.elasticsearch.xpack.core.watcher.watch.Watch;
|
||||
|
@ -385,7 +384,7 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
|
|||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
private void putIngestPipeline(final String pipelineId, final ActionListener<WritePipelineResponse> listener) {
|
||||
private void putIngestPipeline(final String pipelineId, final ActionListener<AcknowledgedResponse> listener) {
|
||||
final String pipelineName = pipelineName(pipelineId);
|
||||
final BytesReference pipeline = BytesReference.bytes(loadPipeline(pipelineId, XContentType.JSON));
|
||||
final PutPipelineRequest request = new PutPipelineRequest(pipelineName, pipeline, XContentType.JSON);
|
||||
|
|
Loading…
Reference in New Issue