-
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.
Add remote allocator for searchable snapshots
Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
- Loading branch information
1 parent
515f84b
commit c0d9171
Showing
19 changed files
with
1,632 additions
and
7 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
69 changes: 69 additions & 0 deletions
69
server/src/main/java/org/opensearch/cluster/routing/RoutingPool.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,69 @@ | ||
/* | ||
* 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; | ||
|
||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.cluster.routing.allocation.RoutingAllocation; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.IndexModule; | ||
|
||
/** | ||
* {@link RoutingPool} defines the different node types based on the assigned capabilities. The methods | ||
* help decide the capabilities of a specific node as well as an index or shard based on the index configuration. | ||
* These methods help with allocation decisions and determining shard classification with the allocation process. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public enum RoutingPool { | ||
LOCAL_ONLY, | ||
REMOTE_CAPABLE; | ||
|
||
/** | ||
* Helps to determine the appropriate {@link RoutingPool} for a given node from the {@link RoutingNode} | ||
*/ | ||
public static RoutingPool getNodePool(RoutingNode node) { | ||
return getNodePool(node.node()); | ||
} | ||
|
||
/** | ||
* Helps to determine the appropriate {@link RoutingPool} for a given node from the {@link DiscoveryNode} | ||
*/ | ||
public static RoutingPool getNodePool(DiscoveryNode node) { | ||
if (node.isSearchNode()) { | ||
return REMOTE_CAPABLE; | ||
} | ||
return LOCAL_ONLY; | ||
} | ||
|
||
/** | ||
* Can determine the appropriate {@link RoutingPool} for a given shard using the {@link IndexMetadata} for the | ||
* index using the {@link RoutingAllocation}. | ||
* @param shard the shard routing for which {@link RoutingPool} has to be determined. | ||
* @param allocation the current allocation of the cluster | ||
* @return {@link RoutingPool} for the given shard. | ||
*/ | ||
public static RoutingPool getShardPool(ShardRouting shard, RoutingAllocation allocation) { | ||
IndexMetadata indexMetadata = allocation.metadata().getIndexSafe(shard.index()); | ||
return getIndexPool(indexMetadata); | ||
} | ||
|
||
/** | ||
* Can determine the appropriate {@link RoutingPool} for a given index using the {@link IndexMetadata}. | ||
* @param indexMetadata the index metadata object for which {@link RoutingPool} has to be determined. | ||
* @return {@link RoutingPool} for the given index. | ||
*/ | ||
public static RoutingPool getIndexPool(IndexMetadata indexMetadata) { | ||
Settings indexSettings = indexMetadata.getSettings(); | ||
if (IndexModule.Type.REMOTE_SNAPSHOT.getSettingsKey().equals(indexSettings.get(IndexModule.INDEX_STORE_TYPE_SETTING.getKey()))) { | ||
return REMOTE_CAPABLE; | ||
} | ||
return LOCAL_ONLY; | ||
} | ||
} |
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.