-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into decommission/contro…
…lled-discovery Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
- Loading branch information
Showing
30 changed files
with
1,468 additions
and
46 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
## 2022-10-04 Version 1.3.6 Release Notes | ||
|
||
### Upgrades | ||
* Update to Netty 4.1.80.Final ([#4379](https://github.com/opensearch-project/OpenSearch/pull/4379)) | ||
* Revert to Netty 4.1.79.Final ([#4433](https://github.com/opensearch-project/OpenSearch/pull/4433)) | ||
* Bumps jackson and snakeyaml dependencies ([#4600](https://github.com/opensearch-project/OpenSearch/pull/4600)) | ||
* Bump commons-configuration2 from 2.7 to 2.8.0 in /plugins/repository-hdfs ([#4646](https://github.com/opensearch-project/OpenSearch/pull/4646)) | ||
|
||
### Bug Fixes | ||
* Set analyzer to regex query string search ([#4220](https://github.com/opensearch-project/OpenSearch/pull/4220)) |
25 changes: 25 additions & 0 deletions
25
rest-api-spec/src/main/resources/rest-api-spec/api/cluster.get_weighted_routing.json
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,25 @@ | ||
{ | ||
"cluster.get_weighted_routing": { | ||
"documentation": { | ||
"url": "https://opensearch.org/docs/latest/opensearch/rest-api/weighted-routing/get", | ||
"description": "Fetches weighted shard routing weights" | ||
}, | ||
"stability": "stable", | ||
"url": { | ||
"paths": [ | ||
{ | ||
"path": "/_cluster/routing/awareness/{attribute}/weights", | ||
"methods": [ | ||
"GET" | ||
], | ||
"parts": { | ||
"attribute": { | ||
"type": "string", | ||
"description": "Awareness attribute name" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
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 @@ | ||
b1e93a735caea94f503e95e6fe79bf9cdc1e985d |
This file was deleted.
Oops, something went wrong.
245 changes: 245 additions & 0 deletions
245
server/src/internalClusterTest/java/org/opensearch/cluster/routing/WeightedRoutingIT.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,245 @@ | ||
/* | ||
* 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.action.admin.cluster.health.ClusterHealthResponse; | ||
import org.opensearch.action.admin.cluster.shards.routing.weighted.get.ClusterGetWeightedRoutingResponse; | ||
import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingResponse; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.TEST, numDataNodes = 0, minNumDataNodes = 3) | ||
public class WeightedRoutingIT extends OpenSearchIntegTestCase { | ||
|
||
public void testPutWeightedRouting() { | ||
Settings commonSettings = Settings.builder() | ||
.put("cluster.routing.allocation.awareness.attributes", "zone") | ||
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b,c") | ||
.build(); | ||
|
||
logger.info("--> starting 6 nodes on different zones"); | ||
int nodeCountPerAZ = 2; | ||
|
||
logger.info("--> starting a dedicated cluster manager node"); | ||
internalCluster().startClusterManagerOnlyNode(Settings.builder().put(commonSettings).build()); | ||
|
||
logger.info("--> starting 1 nodes on zones 'a' & 'b' & 'c'"); | ||
List<String> nodes_in_zone_a = internalCluster().startDataOnlyNodes( | ||
nodeCountPerAZ, | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "a").build() | ||
); | ||
List<String> nodes_in_zone_b = internalCluster().startDataOnlyNodes( | ||
nodeCountPerAZ, | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "b").build() | ||
); | ||
List<String> nodes_in_zone_c = internalCluster().startDataOnlyNodes( | ||
nodeCountPerAZ, | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "c").build() | ||
); | ||
|
||
logger.info("--> waiting for nodes to form a cluster"); | ||
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForNodes("7").execute().actionGet(); | ||
assertThat(health.isTimedOut(), equalTo(false)); | ||
|
||
ensureGreen(); | ||
|
||
logger.info("--> setting shard routing weights for weighted round robin"); | ||
Map<String, Double> weights = Map.of("a", 1.0, "b", 2.0, "c", 3.0); | ||
WeightedRouting weightedRouting = new WeightedRouting("zone", weights); | ||
|
||
ClusterPutWeightedRoutingResponse response = client().admin() | ||
.cluster() | ||
.prepareWeightedRouting() | ||
.setWeightedRouting(weightedRouting) | ||
.get(); | ||
assertEquals(response.isAcknowledged(), true); | ||
|
||
// put call made on a data node in zone a | ||
response = internalCluster().client(randomFrom(nodes_in_zone_a.get(0), nodes_in_zone_a.get(1))) | ||
.admin() | ||
.cluster() | ||
.prepareWeightedRouting() | ||
.setWeightedRouting(weightedRouting) | ||
.get(); | ||
assertEquals(response.isAcknowledged(), true); | ||
} | ||
|
||
public void testPutWeightedRouting_InvalidAwarenessAttribute() { | ||
Settings commonSettings = Settings.builder() | ||
.put("cluster.routing.allocation.awareness.attributes", "zone") | ||
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b,c") | ||
.build(); | ||
|
||
internalCluster().startNodes( | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "a").build(), | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "b").build(), | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "c").build() | ||
); | ||
|
||
logger.info("--> waiting for nodes to form a cluster"); | ||
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForNodes("3").execute().actionGet(); | ||
assertThat(health.isTimedOut(), equalTo(false)); | ||
|
||
ensureGreen(); | ||
|
||
logger.info("--> setting shard routing weights for weighted round robin"); | ||
Map<String, Double> weights = Map.of("a", 1.0, "b", 2.0, "c", 3.0); | ||
WeightedRouting weightedRouting = new WeightedRouting("zone1", weights); | ||
|
||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> client().admin().cluster().prepareWeightedRouting().setWeightedRouting(weightedRouting).get() | ||
); | ||
} | ||
|
||
public void testPutWeightedRouting_MoreThanOneZoneHasZeroWeight() { | ||
Settings commonSettings = Settings.builder() | ||
.put("cluster.routing.allocation.awareness.attributes", "zone") | ||
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b,c") | ||
.build(); | ||
|
||
internalCluster().startNodes( | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "a").build(), | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "b").build(), | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "c").build() | ||
); | ||
|
||
logger.info("--> waiting for nodes to form a cluster"); | ||
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForNodes("3").execute().actionGet(); | ||
assertThat(health.isTimedOut(), equalTo(false)); | ||
|
||
ensureGreen(); | ||
|
||
logger.info("--> setting shard routing weights for weighted round robin"); | ||
Map<String, Double> weights = Map.of("a", 1.0, "b", 0.0, "c", 0.0); | ||
WeightedRouting weightedRouting = new WeightedRouting("zone1", weights); | ||
|
||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> client().admin().cluster().prepareWeightedRouting().setWeightedRouting(weightedRouting).get() | ||
); | ||
} | ||
|
||
public void testGetWeightedRouting_WeightsNotSet() { | ||
Settings commonSettings = Settings.builder() | ||
.put("cluster.routing.allocation.awareness.attributes", "zone") | ||
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b,c") | ||
.build(); | ||
|
||
internalCluster().startNodes( | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "a").build(), | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "b").build(), | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "c").build() | ||
); | ||
|
||
logger.info("--> waiting for nodes to form a cluster"); | ||
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForNodes("3").execute().actionGet(); | ||
assertThat(health.isTimedOut(), equalTo(false)); | ||
|
||
ensureGreen(); | ||
|
||
ClusterGetWeightedRoutingResponse weightedRoutingResponse = client().admin() | ||
.cluster() | ||
.prepareGetWeightedRouting() | ||
.setAwarenessAttribute("zone") | ||
.get(); | ||
assertNull(weightedRoutingResponse.weights()); | ||
} | ||
|
||
public void testGetWeightedRouting_WeightsAreSet() throws IOException { | ||
|
||
Settings commonSettings = Settings.builder() | ||
.put("cluster.routing.allocation.awareness.attributes", "zone") | ||
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b,c") | ||
.build(); | ||
|
||
int nodeCountPerAZ = 2; | ||
|
||
logger.info("--> starting a dedicated cluster manager node"); | ||
internalCluster().startClusterManagerOnlyNode(Settings.builder().put(commonSettings).build()); | ||
|
||
logger.info("--> starting 2 nodes on zones 'a' & 'b' & 'c'"); | ||
List<String> nodes_in_zone_a = internalCluster().startDataOnlyNodes( | ||
nodeCountPerAZ, | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "a").build() | ||
); | ||
List<String> nodes_in_zone_b = internalCluster().startDataOnlyNodes( | ||
nodeCountPerAZ, | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "b").build() | ||
); | ||
List<String> nodes_in_zone_c = internalCluster().startDataOnlyNodes( | ||
nodeCountPerAZ, | ||
Settings.builder().put(commonSettings).put("node.attr.zone", "c").build() | ||
); | ||
|
||
logger.info("--> waiting for nodes to form a cluster"); | ||
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForNodes("7").execute().actionGet(); | ||
assertThat(health.isTimedOut(), equalTo(false)); | ||
|
||
ensureGreen(); | ||
|
||
logger.info("--> setting shard routing weights for weighted round robin"); | ||
Map<String, Double> weights = Map.of("a", 1.0, "b", 2.0, "c", 3.0); | ||
WeightedRouting weightedRouting = new WeightedRouting("zone", weights); | ||
// put api call to set weights | ||
ClusterPutWeightedRoutingResponse response = client().admin() | ||
.cluster() | ||
.prepareWeightedRouting() | ||
.setWeightedRouting(weightedRouting) | ||
.get(); | ||
assertEquals(response.isAcknowledged(), true); | ||
|
||
// get api call to fetch weights | ||
ClusterGetWeightedRoutingResponse weightedRoutingResponse = client().admin() | ||
.cluster() | ||
.prepareGetWeightedRouting() | ||
.setAwarenessAttribute("zone") | ||
.get(); | ||
assertEquals(weightedRouting, weightedRoutingResponse.weights()); | ||
|
||
// get api to fetch local node weight for a node in zone a | ||
weightedRoutingResponse = internalCluster().client(randomFrom(nodes_in_zone_a.get(0), nodes_in_zone_a.get(1))) | ||
.admin() | ||
.cluster() | ||
.prepareGetWeightedRouting() | ||
.setAwarenessAttribute("zone") | ||
.setRequestLocal(true) | ||
.get(); | ||
assertEquals(weightedRouting, weightedRoutingResponse.weights()); | ||
assertEquals("1.0", weightedRoutingResponse.getLocalNodeWeight()); | ||
|
||
// get api to fetch local node weight for a node in zone b | ||
weightedRoutingResponse = internalCluster().client(randomFrom(nodes_in_zone_b.get(0), nodes_in_zone_b.get(1))) | ||
.admin() | ||
.cluster() | ||
.prepareGetWeightedRouting() | ||
.setAwarenessAttribute("zone") | ||
.setRequestLocal(true) | ||
.get(); | ||
assertEquals(weightedRouting, weightedRoutingResponse.weights()); | ||
assertEquals("2.0", weightedRoutingResponse.getLocalNodeWeight()); | ||
|
||
// get api to fetch local node weight for a node in zone c | ||
weightedRoutingResponse = internalCluster().client(randomFrom(nodes_in_zone_c.get(0), nodes_in_zone_c.get(1))) | ||
.admin() | ||
.cluster() | ||
.prepareGetWeightedRouting() | ||
.setAwarenessAttribute("zone") | ||
.setRequestLocal(true) | ||
.get(); | ||
assertEquals(weightedRouting, weightedRoutingResponse.weights()); | ||
assertEquals("3.0", weightedRoutingResponse.getLocalNodeWeight()); | ||
} | ||
} |
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.