Adjust CCR Actions after RequestBuilder is removed

CCR side of #30966
This commit is contained in:
Nhat Nguyen 2018-06-01 23:09:59 -04:00
parent a527095b8d
commit 9564b60194
7 changed files with 17 additions and 45 deletions

View File

@ -48,8 +48,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexAction.Request, CreateAndFollowIndexAction.Response,
CreateAndFollowIndexAction.RequestBuilder> {
public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexAction.Request, CreateAndFollowIndexAction.Response> {
public static final CreateAndFollowIndexAction INSTANCE = new CreateAndFollowIndexAction();
public static final String NAME = "cluster:admin/xpack/ccr/create_and_follow_index";
@ -58,11 +57,6 @@ public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexActio
super(NAME);
}
@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client);
}
@Override
public Response newResponse() {
return new Response();
@ -155,7 +149,7 @@ public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexActio
}
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, CreateAndFollowIndexAction.RequestBuilder> {
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
RequestBuilder(ElasticsearchClient client) {
super(client, INSTANCE, new Request());
@ -254,7 +248,7 @@ public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexActio
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
IndexMetaData.Builder imdBuilder = IndexMetaData.builder(followIndex);
// Copy all settings, but overwrite a few settings.
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(leaderIndexMetaData.getSettings());
@ -263,7 +257,7 @@ public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexActio
settingsBuilder.put(IndexMetaData.SETTING_INDEX_PROVIDED_NAME, followIndex);
settingsBuilder.put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), true);
imdBuilder.settings(settingsBuilder);
// Copy mappings from leader IMD to follow IMD
for (ObjectObjectCursor<String, MappingMetaData> cursor : leaderIndexMetaData.getMappings()) {
imdBuilder.putMapping(cursor.value);
@ -281,10 +275,10 @@ public class CreateAndFollowIndexAction extends Action<CreateAndFollowIndexActio
updatedState = allocationService.reroute(
ClusterState.builder(updatedState).routingTable(routingTableBuilder.build()).build(),
"follow index [" + request.getFollowRequest().getFollowIndex() + "] created");
logger.info("[{}] creating index, cause [ccr_create_and_follow], shards [{}]/[{}]",
followIndex, followIMD.getNumberOfShards(), followIMD.getNumberOfReplicas());
return updatedState;
}
});

View File

@ -40,8 +40,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReferenceArray;
import java.util.stream.Collectors;
public class FollowIndexAction extends Action<FollowIndexAction.Request,
FollowIndexAction.Response, FollowIndexAction.RequestBuilder> {
public class FollowIndexAction extends Action<FollowIndexAction.Request, FollowIndexAction.Response> {
public static final FollowIndexAction INSTANCE = new FollowIndexAction();
public static final String NAME = "cluster:admin/xpack/ccr/follow_index";
@ -50,11 +49,6 @@ public class FollowIndexAction extends Action<FollowIndexAction.Request,
super(NAME);
}
@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client, this);
}
@Override
public Response newResponse() {
return new Response();
@ -134,9 +128,9 @@ public class FollowIndexAction extends Action<FollowIndexAction.Request,
}
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, FollowIndexAction.RequestBuilder> {
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
RequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action) {
RequestBuilder(ElasticsearchClient client, Action<Request, Response> action) {
super(client, action, new Request());
}
}

View File

@ -39,7 +39,7 @@ import java.util.Objects;
import static org.elasticsearch.action.ValidateActions.addValidationError;
public class ShardChangesAction extends Action<ShardChangesAction.Request, ShardChangesAction.Response, ShardChangesAction.RequestBuilder> {
public class ShardChangesAction extends Action<ShardChangesAction.Request, ShardChangesAction.Response> {
public static final ShardChangesAction INSTANCE = new ShardChangesAction();
public static final String NAME = "indices:data/read/xpack/ccr/shard_changes";
@ -48,11 +48,6 @@ public class ShardChangesAction extends Action<ShardChangesAction.Request, Shard
super(NAME);
}
@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client, this);
}
@Override
public Response newResponse() {
return new Response();
@ -209,7 +204,7 @@ public class ShardChangesAction extends Action<ShardChangesAction.Request, Shard
static class RequestBuilder extends SingleShardOperationRequestBuilder<Request, Response, RequestBuilder> {
RequestBuilder(ElasticsearchClient client, Action<Request, Response, RequestBuilder> action) {
RequestBuilder(ElasticsearchClient client, Action<Request, Response> action) {
super(client, action, new Request());
}
}

View File

@ -427,8 +427,8 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor<ShardFollo
protected <
Request extends ActionRequest,
Response extends ActionResponse,
RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>>
void doExecute(Action<Request, Response, RequestBuilder> action, Request request, ActionListener<Response> listener) {
RequestBuilder extends ActionRequestBuilder<Request, Response>>
void doExecute(Action<Request, Response> action, Request request, ActionListener<Response> listener) {
final Supplier<ThreadContext.StoredContext> supplier = threadContext.newRestorableContext(false);
try (ThreadContext.StoredContext ignore = stashWithHeaders(threadContext, filteredHeaders)) {
super.doExecute(action, request, new ContextPreservingActionListener<>(supplier, listener));

View File

@ -31,8 +31,7 @@ import java.io.IOException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReferenceArray;
public class UnfollowIndexAction extends Action<UnfollowIndexAction.Request, UnfollowIndexAction.Response,
UnfollowIndexAction.RequestBuilder> {
public class UnfollowIndexAction extends Action<UnfollowIndexAction.Request, UnfollowIndexAction.Response> {
public static final UnfollowIndexAction INSTANCE = new UnfollowIndexAction();
public static final String NAME = "cluster:admin/xpack/ccr/unfollow_index";
@ -41,11 +40,6 @@ public class UnfollowIndexAction extends Action<UnfollowIndexAction.Request, Unf
super(NAME);
}
@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client);
}
@Override
public Response newResponse() {
return new Response();
@ -104,7 +98,7 @@ public class UnfollowIndexAction extends Action<UnfollowIndexAction.Request, Unf
}
public static class RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder> {
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
RequestBuilder(ElasticsearchClient client) {
super(client, INSTANCE, new Request());

View File

@ -9,7 +9,7 @@ import org.elasticsearch.action.Action;
import org.elasticsearch.client.ElasticsearchClient;
public class BulkShardOperationsAction
extends Action<BulkShardOperationsRequest, BulkShardOperationsResponse, BulkShardOperationsRequestBuilder> {
extends Action<BulkShardOperationsRequest, BulkShardOperationsResponse> {
public static final BulkShardOperationsAction INSTANCE = new BulkShardOperationsAction();
public static final String NAME = "indices:data/write/bulk_shard_operations[s]";
@ -18,11 +18,6 @@ public class BulkShardOperationsAction
super(NAME);
}
@Override
public BulkShardOperationsRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new BulkShardOperationsRequestBuilder(client);
}
@Override
public BulkShardOperationsResponse newResponse() {
return new BulkShardOperationsResponse();

View File

@ -9,7 +9,7 @@ import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;
public class BulkShardOperationsRequestBuilder
extends ActionRequestBuilder<BulkShardOperationsRequest, BulkShardOperationsResponse, BulkShardOperationsRequestBuilder> {
extends ActionRequestBuilder<BulkShardOperationsRequest, BulkShardOperationsResponse> {
public BulkShardOperationsRequestBuilder(final ElasticsearchClient client) {
super(client, BulkShardOperationsAction.INSTANCE, new BulkShardOperationsRequest());