Skip to content

Commit

Permalink
Removing unused ReindexDataStreamAction.Response class (elastic#120321)
Browse files Browse the repository at this point in the history
  • Loading branch information
masseyke authored Jan 16, 2025
1 parent 29b5e87 commit 5832e3c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xpack.migrate.MigratePlugin;
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamRequest;
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamResponse;
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamEnrichedStatus;
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTask;

Expand Down Expand Up @@ -61,8 +60,7 @@ public void testNonExistentDataStream() {
);
assertThrows(
ResourceNotFoundException.class,
() -> client().execute(new ActionType<ReindexDataStreamResponse>(ReindexDataStreamAction.NAME), reindexDataStreamRequest)
.actionGet()
() -> client().execute(new ActionType<AcknowledgedResponse>(ReindexDataStreamAction.NAME), reindexDataStreamRequest).actionGet()
);
}

Expand All @@ -74,12 +72,11 @@ public void testAlreadyUpToDateDataStream() throws Exception {
dataStreamName
);
final int backingIndexCount = createDataStream(dataStreamName);
ReindexDataStreamResponse response = client().execute(
new ActionType<ReindexDataStreamResponse>(ReindexDataStreamAction.NAME),
AcknowledgedResponse response = client().execute(
new ActionType<AcknowledgedResponse>(ReindexDataStreamAction.NAME),
reindexDataStreamRequest
).actionGet();
String persistentTaskId = response.getTaskId();
assertThat(persistentTaskId, equalTo("reindex-data-stream-" + dataStreamName));
String persistentTaskId = "reindex-data-stream-" + dataStreamName;
AtomicReference<ReindexDataStreamTask> runningTask = new AtomicReference<>();
for (TransportService transportService : internalCluster().getInstances(TransportService.class)) {
TaskManager taskManager = transportService.getTaskManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.util.FeatureFlag;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.xcontent.ConstructingObjectParser;
import org.elasticsearch.xcontent.ParseField;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser;

Expand All @@ -29,7 +28,7 @@
import java.util.Objects;
import java.util.function.Predicate;

public class ReindexDataStreamAction extends ActionType<ReindexDataStreamAction.ReindexDataStreamResponse> {
public class ReindexDataStreamAction extends ActionType<AcknowledgedResponse> {
public static final FeatureFlag REINDEX_DATA_STREAM_FEATURE_FLAG = new FeatureFlag("reindex_data_stream");
public static final String TASK_ID_PREFIX = "reindex-data-stream-";

Expand All @@ -47,48 +46,6 @@ public enum Mode {
UPGRADE
}

public static class ReindexDataStreamResponse extends ActionResponse implements ToXContentObject {
private final String taskId;

public ReindexDataStreamResponse(String taskId) {
super();
this.taskId = taskId;
}

public ReindexDataStreamResponse(StreamInput in) throws IOException {
super(in);
this.taskId = in.readString();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(taskId);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("acknowledged", true);
builder.endObject();
return builder;
}

public String getTaskId() {
return taskId;
}

@Override
public int hashCode() {
return Objects.hashCode(taskId);
}

@Override
public boolean equals(Object other) {
return other instanceof ReindexDataStreamResponse && taskId.equals(((ReindexDataStreamResponse) other).taskId);
}

}

public static class ReindexDataStreamRequest extends ActionRequest implements IndicesRequest, ToXContent {
private final Mode mode;
private final String sourceDataStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.cluster.metadata.DataStream;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.service.ClusterService;
Expand All @@ -22,7 +23,6 @@
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.ClientHelper;
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamRequest;
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamResponse;
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTask;
import org.elasticsearch.xpack.migrate.task.ReindexDataStreamTaskParams;

Expand All @@ -33,7 +33,7 @@
* This transport action creates a new persistent task for reindexing the source data stream given in the request. On successful creation
* of the persistent task, it responds with the persistent task id so that the user can monitor the persistent task.
*/
public class ReindexDataStreamTransportAction extends HandledTransportAction<ReindexDataStreamRequest, ReindexDataStreamResponse> {
public class ReindexDataStreamTransportAction extends HandledTransportAction<ReindexDataStreamRequest, AcknowledgedResponse> {
private final PersistentTasksService persistentTasksService;
private final TransportService transportService;
private final ClusterService clusterService;
Expand All @@ -59,7 +59,7 @@ public ReindexDataStreamTransportAction(
}

@Override
protected void doExecute(Task task, ReindexDataStreamRequest request, ActionListener<ReindexDataStreamResponse> listener) {
protected void doExecute(Task task, ReindexDataStreamRequest request, ActionListener<AcknowledgedResponse> listener) {
String sourceDataStreamName = request.getSourceDataStream();
Metadata metadata = clusterService.state().metadata();
DataStream dataStream = metadata.dataStreams().get(sourceDataStreamName);
Expand All @@ -82,7 +82,7 @@ protected void doExecute(Task task, ReindexDataStreamRequest request, ActionList
ReindexDataStreamTask.TASK_NAME,
params,
null,
ActionListener.wrap(startedTask -> listener.onResponse(new ReindexDataStreamResponse(persistentTaskId)), listener::onFailure)
ActionListener.wrap(startedTask -> listener.onResponse(AcknowledgedResponse.TRUE), listener::onFailure)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.elasticsearch.xpack.migrate.rest;

import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.internal.node.NodeClient;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestChannel;
Expand All @@ -17,7 +18,6 @@
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction;
import org.elasticsearch.xpack.migrate.action.ReindexDataStreamAction.ReindexDataStreamResponse;

import java.io.IOException;
import java.util.Collections;
Expand Down Expand Up @@ -63,14 +63,14 @@ public Set<String> supportedCapabilities() {
return Collections.unmodifiableSet(capabilities);
}

static class ReindexDataStreamRestToXContentListener extends RestBuilderListener<ReindexDataStreamResponse> {
static class ReindexDataStreamRestToXContentListener extends RestBuilderListener<AcknowledgedResponse> {

ReindexDataStreamRestToXContentListener(RestChannel channel) {
super(channel);
}

@Override
public RestResponse buildResponse(ReindexDataStreamResponse response, XContentBuilder builder) throws Exception {
public RestResponse buildResponse(AcknowledgedResponse response, XContentBuilder builder) throws Exception {
response.toXContent(builder, channel.request());
return new RestResponse(RestStatus.OK, builder);
}
Expand Down

This file was deleted.

0 comments on commit 5832e3c

Please sign in to comment.