-
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.
[Remote Routing Table] Initial commit for RemoteRoutingTableService s…
…etup (#13304) * Initial commit for RemoteRoutingTableService setup Signed-off-by: Himshikha Gupta <[email protected]> (cherry picked from commit 5121409)
- Loading branch information
Showing
13 changed files
with
551 additions
and
9 deletions.
There are no files selected for viewing
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
67 changes: 67 additions & 0 deletions
67
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,67 @@ | ||
/* | ||
* 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.common.lifecycle.AbstractLifecycleComponent; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.common.util.io.IOUtils; | ||
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.IOException; | ||
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 extends AbstractLifecycleComponent { | ||
|
||
private static final Logger logger = LogManager.getLogger(RemoteRoutingTableService.class); | ||
private final Settings settings; | ||
private final Supplier<RepositoriesService> repositoriesService; | ||
private BlobStoreRepository blobStoreRepository; | ||
|
||
public RemoteRoutingTableService(Supplier<RepositoriesService> repositoriesService, Settings settings) { | ||
assert isRemoteRoutingTableEnabled(settings) : "Remote routing table is not enabled"; | ||
this.repositoriesService = repositoriesService; | ||
this.settings = settings; | ||
} | ||
|
||
@Override | ||
protected void doClose() throws IOException { | ||
if (blobStoreRepository != null) { | ||
IOUtils.close(blobStoreRepository); | ||
} | ||
} | ||
|
||
@Override | ||
protected void doStart() { | ||
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; | ||
} | ||
|
||
@Override | ||
protected void doStop() {} | ||
|
||
} |
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
Oops, something went wrong.