@@ -124,7 +124,8 @@ public RepositoryMetaData getMetadata() {
124124 public SnapshotInfo getSnapshotInfo (SnapshotId snapshotId ) {
125125 assert SNAPSHOT_ID .equals (snapshotId ) : "RemoteClusterRepository only supports " + SNAPSHOT_ID + " as the SnapshotId" ;
126126 Client remoteClient = client .getRemoteClusterClient (remoteClusterAlias );
127- ClusterStateResponse response = remoteClient .admin ().cluster ().prepareState ().clear ().setMetaData (true ).setNodes (true ).get ();
127+ ClusterStateResponse response = remoteClient .admin ().cluster ().prepareState ().clear ().setMetaData (true ).setNodes (true )
128+ .get (ccrSettings .getRecoveryActionTimeout ());
128129 ImmutableOpenMap <String , IndexMetaData > indicesMap = response .getState ().metaData ().indices ();
129130 ArrayList <String > indices = new ArrayList <>(indicesMap .size ());
130131 indicesMap .keysIt ().forEachRemaining (indices ::add );
@@ -138,7 +139,8 @@ public MetaData getSnapshotGlobalMetaData(SnapshotId snapshotId) {
138139 Client remoteClient = client .getRemoteClusterClient (remoteClusterAlias );
139140 // We set a single dummy index name to avoid fetching all the index data
140141 ClusterStateRequest clusterStateRequest = CcrRequests .metaDataRequest ("dummy_index_name" );
141- ClusterStateResponse clusterState = remoteClient .admin ().cluster ().state (clusterStateRequest ).actionGet ();
142+ ClusterStateResponse clusterState = remoteClient .admin ().cluster ().state (clusterStateRequest )
143+ .actionGet (ccrSettings .getRecoveryActionTimeout ());
142144 return clusterState .getState ().metaData ();
143145 }
144146
@@ -149,13 +151,14 @@ public IndexMetaData getSnapshotIndexMetaData(SnapshotId snapshotId, IndexId ind
149151 Client remoteClient = client .getRemoteClusterClient (remoteClusterAlias );
150152
151153 ClusterStateRequest clusterStateRequest = CcrRequests .metaDataRequest (leaderIndex );
152- ClusterStateResponse clusterState = remoteClient .admin ().cluster ().state (clusterStateRequest ).actionGet ();
154+ ClusterStateResponse clusterState = remoteClient .admin ().cluster ().state (clusterStateRequest )
155+ .actionGet (ccrSettings .getRecoveryActionTimeout ());
153156
154157 // Validates whether the leader cluster has been configured properly:
155158 PlainActionFuture <String []> future = PlainActionFuture .newFuture ();
156159 IndexMetaData leaderIndexMetaData = clusterState .getState ().metaData ().index (leaderIndex );
157160 ccrLicenseChecker .fetchLeaderHistoryUUIDs (remoteClient , leaderIndexMetaData , future ::onFailure , future ::onResponse );
158- String [] leaderHistoryUUIDs = future .actionGet ();
161+ String [] leaderHistoryUUIDs = future .actionGet (ccrSettings . getRecoveryActionTimeout () );
159162
160163 IndexMetaData .Builder imdBuilder = IndexMetaData .builder (leaderIndexMetaData );
161164 // Adding the leader index uuid for each shard as custom metadata:
@@ -172,7 +175,8 @@ public IndexMetaData getSnapshotIndexMetaData(SnapshotId snapshotId, IndexId ind
172175 @ Override
173176 public RepositoryData getRepositoryData () {
174177 Client remoteClient = client .getRemoteClusterClient (remoteClusterAlias );
175- ClusterStateResponse response = remoteClient .admin ().cluster ().prepareState ().clear ().setMetaData (true ).get ();
178+ ClusterStateResponse response = remoteClient .admin ().cluster ().prepareState ().clear ().setMetaData (true )
179+ .get (ccrSettings .getRecoveryActionTimeout ());
176180 MetaData remoteMetaData = response .getState ().getMetaData ();
177181
178182 Map <String , SnapshotId > copiedSnapshotIds = new HashMap <>();
@@ -282,7 +286,8 @@ public IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, Ve
282286
283287 private void maybeUpdateMappings (Client localClient , Client remoteClient , Index leaderIndex , IndexSettings followerIndexSettings ) {
284288 ClusterStateRequest clusterStateRequest = CcrRequests .metaDataRequest (leaderIndex .getName ());
285- ClusterStateResponse clusterState = remoteClient .admin ().cluster ().state (clusterStateRequest ).actionGet ();
289+ ClusterStateResponse clusterState = remoteClient .admin ().cluster ().state (clusterStateRequest )
290+ .actionGet (ccrSettings .getRecoveryActionTimeout ());
286291 IndexMetaData leaderIndexMetadata = clusterState .getState ().metaData ().getIndexSafe (leaderIndex );
287292 long leaderMappingVersion = leaderIndexMetadata .getMappingVersion ();
288293
@@ -292,17 +297,17 @@ private void maybeUpdateMappings(Client localClient, Client remoteClient, Index
292297 leaderIndexMetadata .getMappings ().size () + "]" ;
293298 MappingMetaData mappingMetaData = leaderIndexMetadata .getMappings ().iterator ().next ().value ;
294299 PutMappingRequest putMappingRequest = CcrRequests .putMappingRequest (followerIndex .getName (), mappingMetaData );
295- localClient .admin ().indices ().putMapping (putMappingRequest ).actionGet ();
300+ localClient .admin ().indices ().putMapping (putMappingRequest ).actionGet (ccrSettings . getRecoveryActionTimeout () );
296301 }
297302 }
298303
299304 private RestoreSession openSession (String repositoryName , Client remoteClient , ShardId leaderShardId , IndexShard indexShard ,
300305 RecoveryState recoveryState ) {
301306 String sessionUUID = UUIDs .randomBase64UUID ();
302307 PutCcrRestoreSessionAction .PutCcrRestoreSessionResponse response = remoteClient .execute (PutCcrRestoreSessionAction .INSTANCE ,
303- new PutCcrRestoreSessionRequest (sessionUUID , leaderShardId )).actionGet ();
308+ new PutCcrRestoreSessionRequest (sessionUUID , leaderShardId )).actionGet (ccrSettings . getRecoveryActionTimeout () );
304309 return new RestoreSession (repositoryName , remoteClient , sessionUUID , response .getNode (), indexShard , recoveryState ,
305- response .getStoreFileMetaData (), ccrSettings . getRateLimiter () , throttledTime ::inc );
310+ response .getStoreFileMetaData (), ccrSettings , throttledTime ::inc );
306311 }
307312
308313 private static class RestoreSession extends FileRestoreContext implements Closeable {
@@ -313,18 +318,18 @@ private static class RestoreSession extends FileRestoreContext implements Closea
313318 private final String sessionUUID ;
314319 private final DiscoveryNode node ;
315320 private final Store .MetadataSnapshot sourceMetaData ;
316- private final CombinedRateLimiter rateLimiter ;
321+ private final CcrSettings ccrSettings ;
317322 private final LongConsumer throttleListener ;
318323
319324 RestoreSession (String repositoryName , Client remoteClient , String sessionUUID , DiscoveryNode node , IndexShard indexShard ,
320- RecoveryState recoveryState , Store .MetadataSnapshot sourceMetaData , CombinedRateLimiter rateLimiter ,
325+ RecoveryState recoveryState , Store .MetadataSnapshot sourceMetaData , CcrSettings ccrSettings ,
321326 LongConsumer throttleListener ) {
322327 super (repositoryName , indexShard , SNAPSHOT_ID , recoveryState , BUFFER_SIZE );
323328 this .remoteClient = remoteClient ;
324329 this .sessionUUID = sessionUUID ;
325330 this .node = node ;
326331 this .sourceMetaData = sourceMetaData ;
327- this .rateLimiter = rateLimiter ;
332+ this .ccrSettings = ccrSettings ;
328333 this .throttleListener = throttleListener ;
329334 }
330335
@@ -340,14 +345,14 @@ void restoreFiles() throws IOException {
340345
341346 @ Override
342347 protected InputStream fileInputStream (BlobStoreIndexShardSnapshot .FileInfo fileInfo ) {
343- return new RestoreFileInputStream (remoteClient , sessionUUID , node , fileInfo .metadata (), rateLimiter , throttleListener );
348+ return new RestoreFileInputStream (remoteClient , sessionUUID , node , fileInfo .metadata (), ccrSettings , throttleListener );
344349 }
345350
346351 @ Override
347352 public void close () {
348353 ClearCcrRestoreSessionRequest clearRequest = new ClearCcrRestoreSessionRequest (sessionUUID , node );
349354 ClearCcrRestoreSessionAction .ClearCcrRestoreSessionResponse response =
350- remoteClient .execute (ClearCcrRestoreSessionAction .INSTANCE , clearRequest ).actionGet ();
355+ remoteClient .execute (ClearCcrRestoreSessionAction .INSTANCE , clearRequest ).actionGet (ccrSettings . getRecoveryActionTimeout () );
351356 }
352357 }
353358
@@ -358,17 +363,19 @@ private static class RestoreFileInputStream extends InputStream {
358363 private final DiscoveryNode node ;
359364 private final StoreFileMetaData fileToRecover ;
360365 private final CombinedRateLimiter rateLimiter ;
366+ private final CcrSettings ccrSettings ;
361367 private final LongConsumer throttleListener ;
362368
363369 private long pos = 0 ;
364370
365371 private RestoreFileInputStream (Client remoteClient , String sessionUUID , DiscoveryNode node , StoreFileMetaData fileToRecover ,
366- CombinedRateLimiter rateLimiter , LongConsumer throttleListener ) {
372+ CcrSettings ccrSettings , LongConsumer throttleListener ) {
367373 this .remoteClient = remoteClient ;
368374 this .sessionUUID = sessionUUID ;
369375 this .node = node ;
370376 this .fileToRecover = fileToRecover ;
371- this .rateLimiter = rateLimiter ;
377+ this .ccrSettings = ccrSettings ;
378+ this .rateLimiter = ccrSettings .getRateLimiter ();
372379 this .throttleListener = throttleListener ;
373380 }
374381
@@ -393,7 +400,7 @@ public int read(byte[] bytes, int off, int len) throws IOException {
393400 String fileName = fileToRecover .name ();
394401 GetCcrRestoreFileChunkRequest request = new GetCcrRestoreFileChunkRequest (node , sessionUUID , fileName , bytesRequested );
395402 GetCcrRestoreFileChunkAction .GetCcrRestoreFileChunkResponse response =
396- remoteClient .execute (GetCcrRestoreFileChunkAction .INSTANCE , request ).actionGet ();
403+ remoteClient .execute (GetCcrRestoreFileChunkAction .INSTANCE , request ).actionGet (ccrSettings . getRecoveryActionTimeout () );
397404 BytesReference fileChunk = response .getChunk ();
398405
399406 int bytesReceived = fileChunk .length ();
0 commit comments