File tree Expand file tree Collapse file tree 3 files changed +14
-17
lines changed
main/java/org/opensearch/cluster/metadata
test/java/org/opensearch/cluster/metadata Expand file tree Collapse file tree 3 files changed +14
-17
lines changed Original file line number Diff line number Diff line change @@ -1008,22 +1008,18 @@ static Settings aggregateIndexSettings(
1008
1008
1009
1009
private static void updateSearchOnlyReplicas (Settings requestSettings , Settings .Builder builder ) {
1010
1010
if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING .exists (builder ) && builder .get (SETTING_NUMBER_OF_SEARCH_REPLICAS ) != null ) {
1011
+ if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING .get (requestSettings ) > 0
1012
+ && ReplicationType .parseString (builder .get (INDEX_REPLICATION_TYPE_SETTING .getKey ())).equals (ReplicationType .DOCUMENT )) {
1013
+ throw new IllegalArgumentException (
1014
+ "To set "
1015
+ + SETTING_NUMBER_OF_SEARCH_REPLICAS
1016
+ + ", "
1017
+ + INDEX_REPLICATION_TYPE_SETTING .getKey ()
1018
+ + " must be set to "
1019
+ + ReplicationType .SEGMENT
1020
+ );
1021
+ }
1011
1022
builder .put (SETTING_NUMBER_OF_SEARCH_REPLICAS , INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING .get (requestSettings ));
1012
- } else {
1013
- // ensure we always set the default on creation to a nonnull value.
1014
- // TODO: Maybe allow a cluster wide default for search replica count when SR is default strategy
1015
- builder .put (SETTING_NUMBER_OF_SEARCH_REPLICAS , INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING .getDefault (requestSettings ));
1016
- }
1017
- if (INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING .get (requestSettings ) > 0
1018
- && ReplicationType .parseString (builder .get (INDEX_REPLICATION_TYPE_SETTING .getKey ())).equals (ReplicationType .DOCUMENT )) {
1019
- throw new IllegalArgumentException (
1020
- "To set "
1021
- + SETTING_NUMBER_OF_SEARCH_REPLICAS
1022
- + ", "
1023
- + INDEX_REPLICATION_TYPE_SETTING .getKey ()
1024
- + " must be set to "
1025
- + ReplicationType .SEGMENT
1026
- );
1027
1023
}
1028
1024
}
1029
1025
Original file line number Diff line number Diff line change @@ -270,7 +270,7 @@ public ClusterState execute(ClusterState currentState) {
270
270
}
271
271
final int updatedNumberOfSearchReplicas = IndexMetadata .INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING .get (openSettings );
272
272
if (preserveExisting == false ) {
273
- // TODO: Maybe honor awareness validation to search replicas?
273
+ // TODO: Honor awareness validation to search replicas.
274
274
275
275
// Verify that this won't take us over the cluster shard limit.
276
276
int totalNewShards = Arrays .stream (request .indices ())
Original file line number Diff line number Diff line change 128
128
import static java .util .Collections .singleton ;
129
129
import static java .util .Collections .singletonList ;
130
130
import static org .opensearch .cluster .metadata .IndexMetadata .INDEX_NUMBER_OF_ROUTING_SHARDS_SETTING ;
131
+ import static org .opensearch .cluster .metadata .IndexMetadata .INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING ;
131
132
import static org .opensearch .cluster .metadata .IndexMetadata .INDEX_NUMBER_OF_SHARDS_SETTING ;
132
133
import static org .opensearch .cluster .metadata .IndexMetadata .INDEX_READ_ONLY_BLOCK ;
133
134
import static org .opensearch .cluster .metadata .IndexMetadata .INDEX_REPLICATION_TYPE_SETTING ;
@@ -2250,7 +2251,7 @@ public void testDefaultSearchReplicasSetting() {
2250
2251
Collections .emptySet (),
2251
2252
clusterSettings
2252
2253
);
2253
- assertEquals ( "0" , indexSettings . get ( SETTING_NUMBER_OF_SEARCH_REPLICAS ));
2254
+ assertFalse ( INDEX_NUMBER_OF_SEARCH_REPLICAS_SETTING . exists ( indexSettings ));
2254
2255
}
2255
2256
2256
2257
public void testSearchReplicasValidationWithSegmentReplication () {
You can’t perform that action at this time.
0 commit comments