-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for RemoteRoutingTableService setup
Signed-off-by: Himshikha Gupta <himshikh@amazon.com>
- Loading branch information
Showing
7 changed files
with
168 additions
and
2 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
server/src/main/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cluster.routing.remote; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.cluster.ClusterState; | ||
import org.opensearch.cluster.routing.RoutingTable; | ||
import org.opensearch.common.settings.ClusterSettings; | ||
import org.opensearch.common.settings.Setting; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.util.io.IOUtils; | ||
import org.opensearch.gateway.remote.ClusterMetadataManifest; | ||
import org.opensearch.node.Node; | ||
import org.opensearch.node.remotestore.RemoteStoreNodeAttribute; | ||
import org.opensearch.repositories.RepositoriesService; | ||
import org.opensearch.repositories.Repository; | ||
import org.opensearch.repositories.blobstore.BlobStoreRepository; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.isRemoteRoutingTableEnabled; | ||
|
||
/** | ||
* A Service which provides APIs to upload and download routing table from remote store. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class RemoteRoutingTableService implements Closeable { | ||
|
||
/** | ||
* Cluster setting to specify if routing table should be published to remote store | ||
*/ | ||
public static final Setting<Boolean> REMOTE_ROUTING_TABLE_ENABLED_SETTING = Setting.boolSetting( | ||
"cluster.remote_store.routing.enabled", | ||
false, | ||
Setting.Property.NodeScope, | ||
Setting.Property.Final | ||
); | ||
private static final Logger logger = LogManager.getLogger(RemoteRoutingTableService.class); | ||
private final Settings settings; | ||
private final Supplier<RepositoriesService> repositoriesService; | ||
private final ClusterSettings clusterSettings; | ||
private BlobStoreRepository blobStoreRepository; | ||
|
||
public RemoteRoutingTableService(Supplier<RepositoriesService> repositoriesService, | ||
Settings settings, | ||
ClusterSettings clusterSettings) { | ||
assert isRemoteRoutingTableEnabled(settings) : "Remote routing table is not enabled"; | ||
this.repositoriesService = repositoriesService; | ||
this.settings = settings; | ||
this.clusterSettings = clusterSettings; | ||
} | ||
|
||
public List<ClusterMetadataManifest.UploadedIndexMetadata> writeFullRoutingTable(ClusterState clusterState, String previousClusterUUID) { | ||
return null; | ||
} | ||
|
||
public List<ClusterMetadataManifest.UploadedIndexMetadata> writeIncrementalMetadata( | ||
ClusterState previousClusterState, | ||
ClusterState clusterState, | ||
ClusterMetadataManifest previousManifest) { | ||
return null; | ||
} | ||
|
||
public RoutingTable getLatestRoutingTable(String clusterName, String clusterUUID) { | ||
return null; | ||
} | ||
|
||
public RoutingTable getIncrementalRoutingTable(ClusterState previousClusterState, ClusterMetadataManifest previousManifest, String clusterName, String clusterUUID) { | ||
return null; | ||
} | ||
|
||
private void deleteStaleRoutingTable(String clusterName, String clusterUUID, int manifestsToRetain) { | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
if (blobStoreRepository != null) { | ||
IOUtils.close(blobStoreRepository); | ||
} | ||
} | ||
|
||
public void start() { | ||
assert isRemoteRoutingTableEnabled(settings) == true : "Remote routing table is not enabled"; | ||
final String remoteStoreRepo = settings.get( | ||
Node.NODE_ATTRIBUTES.getKey() + RemoteStoreNodeAttribute.REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY | ||
); | ||
assert remoteStoreRepo != null : "Remote routing table repository is not configured"; | ||
final Repository repository = repositoriesService.get().repository(remoteStoreRepo); | ||
assert repository instanceof BlobStoreRepository : "Repository should be instance of BlobStoreRepository"; | ||
blobStoreRepository = (BlobStoreRepository) repository; | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
server/src/main/java/org/opensearch/cluster/routing/remote/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
/** Package containing class to perform operations on remote routing table */ | ||
package org.opensearch.cluster.routing.remote; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters