Skip to content

Commit

Permalink
Adjust CCR Actions after RequestBuilder is removed
Browse files Browse the repository at this point in the history
CCR side of #30966
  • Loading branch information
dnhatn committed Jun 2, 2018
1 parent a527095 commit 9564b60
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
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";
Expand All @@ -58,11 +57,6 @@ private CreateAndFollowIndexAction() {
super(NAME);
}

@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client);
}

@Override
public Response newResponse() {
return new Response();
Expand Down Expand Up @@ -155,7 +149,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
}
}

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());
Expand Down Expand Up @@ -254,7 +248,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {

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());
Expand All @@ -263,7 +257,7 @@ public ClusterState execute(ClusterState currentState) throws Exception {
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);
Expand All @@ -281,10 +275,10 @@ public ClusterState execute(ClusterState currentState) throws Exception {
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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
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";
Expand All @@ -50,11 +49,6 @@ private FollowIndexAction() {
super(NAME);
}

@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client, this);
}

@Override
public Response newResponse() {
return new Response();
Expand Down Expand Up @@ -134,9 +128,9 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

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";
Expand All @@ -48,11 +48,6 @@ private ShardChangesAction() {
super(NAME);
}

@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client, this);
}

@Override
public Response newResponse() {
return new Response();
Expand Down Expand Up @@ -209,7 +204,7 @@ public int hashCode() {

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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ static Client wrapClient(Client client, ShardFollowTask shardFollowTask) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
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";
Expand All @@ -41,11 +40,6 @@ private UnfollowIndexAction() {
super(NAME);
}

@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client);
}

@Override
public Response newResponse() {
return new Response();
Expand Down Expand Up @@ -104,7 +98,7 @@ public void writeTo(StreamOutput out) throws IOException {

}

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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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]";
Expand All @@ -18,11 +18,6 @@ private BulkShardOperationsAction() {
super(NAME);
}

@Override
public BulkShardOperationsRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new BulkShardOperationsRequestBuilder(client);
}

@Override
public BulkShardOperationsResponse newResponse() {
return new BulkShardOperationsResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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());
Expand Down

0 comments on commit 9564b60

Please sign in to comment.