6565import java .util .stream .Collectors ;
6666
6767public class FollowIndexAction extends Action <FollowIndexAction .Request ,
68- FollowIndexAction . Response , FollowIndexAction .RequestBuilder > {
68+ AcknowledgedResponse , FollowIndexAction .RequestBuilder > {
6969
7070 public static final FollowIndexAction INSTANCE = new FollowIndexAction ();
7171 public static final String NAME = "cluster:admin/xpack/ccr/follow_index" ;
@@ -80,8 +80,8 @@ public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
8080 }
8181
8282 @ Override
83- public Response newResponse () {
84- return new Response ();
83+ public AcknowledgedResponse newResponse () {
84+ return new AcknowledgedResponse ();
8585 }
8686
8787 public static class Request extends ActionRequest implements ToXContentObject {
@@ -137,9 +137,17 @@ public static Request fromXContent(XContentParser parser, String followerIndex)
137137 private TimeValue retryTimeout ;
138138 private TimeValue idleShardRetryDelay ;
139139
140- public Request (String leaderIndex , String followerIndex , Integer maxBatchOperationCount , Integer maxConcurrentReadBatches ,
141- Long maxOperationSizeInBytes , Integer maxConcurrentWriteBatches , Integer maxWriteBufferSize ,
142- TimeValue retryTimeout , TimeValue idleShardRetryDelay ) {
140+ public Request (
141+ String leaderIndex ,
142+ String followerIndex ,
143+ Integer maxBatchOperationCount ,
144+ Integer maxConcurrentReadBatches ,
145+ Long maxOperationSizeInBytes ,
146+ Integer maxConcurrentWriteBatches ,
147+ Integer maxWriteBufferSize ,
148+ TimeValue retryTimeout ,
149+ TimeValue idleShardRetryDelay ) {
150+
143151 if (leaderIndex == null ) {
144152 throw new IllegalArgumentException ("leader_index is missing" );
145153 }
@@ -279,8 +287,17 @@ public boolean equals(Object o) {
279287
280288 @ Override
281289 public int hashCode () {
282- return Objects .hash (leaderIndex , followerIndex , maxBatchOperationCount , maxConcurrentReadBatches , maxOperationSizeInBytes ,
283- maxConcurrentWriteBatches , maxWriteBufferSize , retryTimeout , idleShardRetryDelay );
290+ return Objects .hash (
291+ leaderIndex ,
292+ followerIndex ,
293+ maxBatchOperationCount ,
294+ maxConcurrentReadBatches ,
295+ maxOperationSizeInBytes ,
296+ maxConcurrentWriteBatches ,
297+ maxWriteBufferSize ,
298+ retryTimeout ,
299+ idleShardRetryDelay
300+ );
284301 }
285302 }
286303
@@ -291,17 +308,7 @@ public static class RequestBuilder extends ActionRequestBuilder<Request, Respons
291308 }
292309 }
293310
294- public static class Response extends AcknowledgedResponse {
295-
296- Response () {
297- }
298-
299- Response (boolean acknowledged ) {
300- super (acknowledged );
301- }
302- }
303-
304- public static class TransportAction extends HandledTransportAction <Request , Response > {
311+ public static class TransportAction extends HandledTransportAction <Request , AcknowledgedResponse > {
305312
306313 private final Client client ;
307314 private final ClusterService clusterService ;
@@ -332,7 +339,7 @@ public TransportAction(
332339 }
333340
334341 @ Override
335- protected void doExecute (final Request request , final ActionListener <Response > listener ) {
342+ protected void doExecute (final Request request , final ActionListener <AcknowledgedResponse > listener ) {
336343 if (ccrLicenseChecker .isCcrAllowed ()) {
337344 final String [] indices = new String []{request .leaderIndex };
338345 final Map <String , List <String >> remoteClusterIndices = remoteClusterService .groupClusterIndices (indices , s -> false );
@@ -351,7 +358,8 @@ protected void doExecute(final Request request, final ActionListener<Response> l
351358 }
352359 }
353360
354- private void followLocalIndex (final Request request , final ActionListener <Response > listener ) {
361+ private void followLocalIndex (final Request request ,
362+ final ActionListener <AcknowledgedResponse > listener ) {
355363 final ClusterState state = clusterService .state ();
356364 final IndexMetaData followerIndexMetadata = state .getMetaData ().index (request .getFollowerIndex ());
357365 // following an index in local cluster, so use local cluster state to fetch leader index metadata
@@ -367,7 +375,7 @@ private void followRemoteIndex(
367375 final Request request ,
368376 final String clusterAlias ,
369377 final String leaderIndex ,
370- final ActionListener <Response > listener ) {
378+ final ActionListener <AcknowledgedResponse > listener ) {
371379 final ClusterState state = clusterService .state ();
372380 final IndexMetaData followerIndexMetadata = state .getMetaData ().index (request .getFollowerIndex ());
373381 ccrLicenseChecker .checkRemoteClusterLicenseAndFetchLeaderIndexMetadata (
@@ -394,8 +402,13 @@ private void followRemoteIndex(
394402 * <li>The leader index and follow index need to have the same number of primary shards</li>
395403 * </ul>
396404 */
397- void start (Request request , String clusterNameAlias , IndexMetaData leaderIndexMetadata , IndexMetaData followIndexMetadata ,
398- ActionListener <Response > handler ) throws IOException {
405+ void start (
406+ Request request ,
407+ String clusterNameAlias ,
408+ IndexMetaData leaderIndexMetadata ,
409+ IndexMetaData followIndexMetadata ,
410+ ActionListener <AcknowledgedResponse > handler ) throws IOException {
411+
399412 MapperService mapperService = followIndexMetadata != null ? indicesService .createIndexMapperService (followIndexMetadata ) : null ;
400413 validate (request , leaderIndexMetadata , followIndexMetadata , mapperService );
401414 final int numShards = followIndexMetadata .getNumberOfShards ();
@@ -443,7 +456,7 @@ void finalizeResponse() {
443456
444457 if (error == null ) {
445458 // include task ids?
446- handler .onResponse (new Response (true ));
459+ handler .onResponse (new AcknowledgedResponse (true ));
447460 } else {
448461 // TODO: cancel all started tasks
449462 handler .onFailure (error );
@@ -506,7 +519,9 @@ void finalizeResponse() {
506519 WHITELISTED_SETTINGS = Collections .unmodifiableSet (whiteListedSettings );
507520 }
508521
509- static void validate (Request request , IndexMetaData leaderIndex , IndexMetaData followIndex , MapperService followerMapperService ) {
522+ static void validate (Request request ,
523+ IndexMetaData leaderIndex ,
524+ IndexMetaData followIndex , MapperService followerMapperService ) {
510525 if (leaderIndex == null ) {
511526 throw new IllegalArgumentException ("leader index [" + request .leaderIndex + "] does not exist" );
512527 }
0 commit comments