@@ -62,24 +62,22 @@ public ReplicationSplitHelper(
6262    }
6363
6464    public  static  <Request  extends  ReplicationRequest <Request >> boolean  needsSplitCoordination (
65-         final  TransportReplicationAction . ConcreteShardRequest < Request >  primaryRequest ,
65+         final  Request  primaryRequest ,
6666        final  IndexMetadata  indexMetadata 
6767    ) {
68-         SplitShardCountSummary  requestSplitSummary  = primaryRequest .getRequest (). reshardSplitShardCountSummary ();
68+         SplitShardCountSummary  requestSplitSummary  = primaryRequest .reshardSplitShardCountSummary ();
6969        // TODO: We currently only set the request split summary transport shard bulk. Only evaluate this at the moment or else every 
7070        // request would say it needs a split. 
7171        return  requestSplitSummary .isUnset () == false 
72-             && requestSplitSummary .equals (
73-                 SplitShardCountSummary .forIndexing (indexMetadata , primaryRequest .getRequest ().shardId ().getId ())
74-             ) == false ;
72+             && requestSplitSummary .equals (SplitShardCountSummary .forIndexing (indexMetadata , primaryRequest .shardId ().getId ())) == false ;
7573    }
7674
7775    public  SplitCoordinator  newSplitRequest (
7876        TransportReplicationAction <Request , ReplicaRequest , Response > action ,
7977        ReplicationTask  task ,
8078        ProjectMetadata  project ,
8179        TransportReplicationAction <Request , ReplicaRequest , Response >.PrimaryShardReference  primaryShardReference ,
82-         TransportReplicationAction . ConcreteShardRequest < Request >  primaryRequest ,
80+         Request  primaryRequest ,
8381        CheckedBiConsumer <
8482            TransportReplicationAction <Request , ReplicaRequest , Response >.PrimaryShardReference ,
8583            ActionListener <Response >,
@@ -103,7 +101,7 @@ public class SplitCoordinator {
103101        private  final  ReplicationTask  task ;
104102        private  final  ProjectMetadata  project ;
105103        private  final  TransportReplicationAction <Request , ReplicaRequest , Response >.PrimaryShardReference  primaryShardReference ;
106-         private  final  TransportReplicationAction . ConcreteShardRequest < Request >  originalRequest ;
104+         private  final  Request  originalRequest ;
107105        private  final  CheckedBiConsumer <
108106            TransportReplicationAction <Request , ReplicaRequest , Response >.PrimaryShardReference ,
109107            ActionListener <Response >,
@@ -115,7 +113,7 @@ public SplitCoordinator(
115113            ReplicationTask  task ,
116114            ProjectMetadata  project ,
117115            TransportReplicationAction <Request , ReplicaRequest , Response >.PrimaryShardReference  primaryShardReference ,
118-             TransportReplicationAction . ConcreteShardRequest < Request >  originalRequest ,
116+             Request  originalRequest ,
119117            CheckedBiConsumer <
120118                TransportReplicationAction <Request , ReplicaRequest , Response >.PrimaryShardReference ,
121119                ActionListener <Response >,
@@ -132,7 +130,7 @@ public SplitCoordinator(
132130        }
133131
134132        public  void  coordinate () throws  Exception  {
135-             Map <ShardId , Request > splitRequests  = action .splitRequestOnPrimary (originalRequest . getRequest () );
133+             Map <ShardId , Request > splitRequests  = action .splitRequestOnPrimary (originalRequest );
136134
137135            int  numSplitRequests  = splitRequests .size ();
138136
@@ -142,7 +140,8 @@ public void coordinate() throws Exception {
142140
143141            if  (numSplitRequests  == 1 ) {
144142                // If the request is for source, same behavior as before 
145-                 if  (splitRequests .containsKey (originalRequest .getRequest ().shardId ())) {
143+                 if  (splitRequests .containsKey (originalRequest .shardId ())) {
144+                     TransportReplicationAction .setPhase (task , "primary" );
146145                    doPrimaryRequest .accept (primaryShardReference , onCompletionListener );
147146                } else  {
148147                    // If the request is for target, forward request to target. 
@@ -198,11 +197,7 @@ public void onFailure(Exception e) {
198197                    }
199198
200199                    private  void  finish () {
201-                         Tuple <Response , Exception > finalResponse  = action .combineSplitResponses (
202-                             originalRequest .getRequest (),
203-                             splitRequests ,
204-                             results 
205-                         );
200+                         Tuple <Response , Exception > finalResponse  = action .combineSplitResponses (originalRequest , splitRequests , results );
206201                        TransportReplicationAction .setPhase (task , "finished" );
207202                        if  (finalResponse .v1 () != null ) {
208203                            onCompletionListener .onResponse (finalResponse .v1 ());
@@ -211,7 +206,7 @@ private void finish() {
211206                        }
212207                    }
213208                };
214-                 if  (splitRequest .getKey ().equals (originalRequest .getRequest (). shardId ())) {
209+                 if  (splitRequest .getKey ().equals (originalRequest .shardId ())) {
215210                    doPrimaryRequest .accept (primaryShardReference , listener );
216211                } else  {
217212                    delegateToTarget (splitRequest .getKey (), splitRequest .getValue (), clusterService ::state , project , listener );
0 commit comments