Skip to content

Commit 5fdebee

Browse files
authored
[Remote Store] Remove stale code for remote restore from Restore Serv… (#9293)
--------- Signed-off-by: bansvaru <[email protected]>
1 parent c9dbd90 commit 5fdebee

File tree

1 file changed

+0
-104
lines changed

1 file changed

+0
-104
lines changed

server/src/main/java/org/opensearch/snapshots/RestoreService.java

Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.opensearch.Version;
3838
import org.opensearch.core.action.ActionListener;
3939
import org.opensearch.action.StepListener;
40-
import org.opensearch.action.admin.cluster.remotestore.restore.RestoreRemoteStoreRequest;
4140
import org.opensearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
4241
import org.opensearch.action.support.IndicesOptions;
4342
import org.opensearch.cluster.ClusterChangedEvent;
@@ -63,10 +62,8 @@
6362
import org.opensearch.cluster.metadata.MetadataIndexUpgradeService;
6463
import org.opensearch.cluster.metadata.RepositoriesMetadata;
6564
import org.opensearch.cluster.node.DiscoveryNode;
66-
import org.opensearch.cluster.routing.IndexShardRoutingTable;
6765
import org.opensearch.cluster.routing.RecoverySource;
6866
import org.opensearch.cluster.routing.RecoverySource.SnapshotRecoverySource;
69-
import org.opensearch.cluster.routing.RecoverySource.RemoteStoreRecoverySource;
7067
import org.opensearch.cluster.routing.RoutingChangesObserver;
7168
import org.opensearch.cluster.routing.RoutingTable;
7269
import org.opensearch.cluster.routing.ShardRouting;
@@ -221,107 +218,6 @@ public RestoreService(
221218

222219
}
223220

224-
/**
225-
* Restores data from remote store for indices specified in the restore request.
226-
*
227-
* @param request restore request
228-
* @param listener restore listener
229-
*/
230-
public void restoreFromRemoteStore(RestoreRemoteStoreRequest request, final ActionListener<RestoreCompletionResponse> listener) {
231-
clusterService.submitStateUpdateTask("restore[remote_store]", new ClusterStateUpdateTask() {
232-
final String restoreUUID = UUIDs.randomBase64UUID();
233-
RestoreInfo restoreInfo = null;
234-
235-
@Override
236-
public ClusterState execute(ClusterState currentState) {
237-
// Updating cluster state
238-
ClusterState.Builder builder = ClusterState.builder(currentState);
239-
Metadata.Builder mdBuilder = Metadata.builder(currentState.metadata());
240-
ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
241-
RoutingTable.Builder rtBuilder = RoutingTable.builder(currentState.routingTable());
242-
243-
List<String> indicesToBeRestored = new ArrayList<>();
244-
int totalShards = 0;
245-
for (String index : request.indices()) {
246-
IndexMetadata currentIndexMetadata = currentState.metadata().index(index);
247-
if (currentIndexMetadata == null) {
248-
// ToDo: Handle index metadata does not exist case. (GitHub #3457)
249-
logger.warn("Remote store restore is not supported for non-existent index. Skipping: {}", index);
250-
continue;
251-
}
252-
if (currentIndexMetadata.getSettings().getAsBoolean(SETTING_REMOTE_STORE_ENABLED, false)) {
253-
IndexMetadata updatedIndexMetadata = currentIndexMetadata;
254-
Map<ShardId, ShardRouting> activeInitializingShards = new HashMap<>();
255-
if (request.restoreAllShards()) {
256-
if (currentIndexMetadata.getState() != IndexMetadata.State.CLOSE) {
257-
throw new IllegalStateException(
258-
"cannot restore index ["
259-
+ index
260-
+ "] because an open index "
261-
+ "with same name already exists in the cluster. Close the existing index"
262-
);
263-
}
264-
updatedIndexMetadata = IndexMetadata.builder(currentIndexMetadata)
265-
.state(IndexMetadata.State.OPEN)
266-
.version(1 + currentIndexMetadata.getVersion())
267-
.mappingVersion(1 + currentIndexMetadata.getMappingVersion())
268-
.settingsVersion(1 + currentIndexMetadata.getSettingsVersion())
269-
.aliasesVersion(1 + currentIndexMetadata.getAliasesVersion())
270-
.build();
271-
} else {
272-
activeInitializingShards = currentState.routingTable()
273-
.index(index)
274-
.shards()
275-
.values()
276-
.stream()
277-
.map(IndexShardRoutingTable::primaryShard)
278-
.filter(shardRouting -> shardRouting.unassigned() == false)
279-
.collect(Collectors.toMap(ShardRouting::shardId, Function.identity()));
280-
}
281-
282-
IndexId indexId = new IndexId(index, updatedIndexMetadata.getIndexUUID());
283-
284-
RemoteStoreRecoverySource recoverySource = new RemoteStoreRecoverySource(
285-
restoreUUID,
286-
updatedIndexMetadata.getCreationVersion(),
287-
indexId
288-
);
289-
rtBuilder.addAsRemoteStoreRestore(updatedIndexMetadata, recoverySource, activeInitializingShards);
290-
blocks.updateBlocks(updatedIndexMetadata);
291-
mdBuilder.put(updatedIndexMetadata, true);
292-
indicesToBeRestored.add(index);
293-
totalShards += updatedIndexMetadata.getNumberOfShards();
294-
} else {
295-
logger.warn("Remote store is not enabled for index: {}", index);
296-
}
297-
}
298-
299-
restoreInfo = new RestoreInfo("remote_store", indicesToBeRestored, totalShards, totalShards);
300-
301-
RoutingTable rt = rtBuilder.build();
302-
ClusterState updatedState = builder.metadata(mdBuilder).blocks(blocks).routingTable(rt).build();
303-
return allocationService.reroute(updatedState, "restored from remote store");
304-
}
305-
306-
@Override
307-
public void onFailure(String source, Exception e) {
308-
logger.warn("failed to restore from remote store", e);
309-
listener.onFailure(e);
310-
}
311-
312-
@Override
313-
public TimeValue timeout() {
314-
return request.masterNodeTimeout();
315-
}
316-
317-
@Override
318-
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
319-
listener.onResponse(new RestoreCompletionResponse(restoreUUID, null, restoreInfo));
320-
}
321-
});
322-
323-
}
324-
325221
/**
326222
* Restores snapshot specified in the restore request.
327223
*

0 commit comments

Comments
 (0)