Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable merge policy and option to choose between LogByteSize and Tiered MergePolicy #9992

Merged
merged 9 commits into from
Oct 2, 2023
Prev Previous commit
Next Next commit
Rename constant DEFAULT to DEFAULT_POLICY
Signed-off-by: Rishabh Maurya <rishabhmaurya05@gmail.com>
  • Loading branch information
rishabhmaurya committed Oct 2, 2023
commit 65d88f6d9c4673357c15efb7dee2034409da9e96
28 changes: 14 additions & 14 deletions server/src/main/java/org/opensearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
*/
@PublicApi(since = "1.0.0")
public final class IndexSettings {
private static final String DEFAULT = "default";
private static final String DEFAULT_POLICY = "default";
private static final String MERGE_ON_FLUSH_MERGE_POLICY = "merge-on-flush";
public static final String TIERED_MERGE_POLICY = "tiered";
public static final String LOG_BYTE_SIZE_MERGE_POLICY = "log_byte_size";
Expand Down Expand Up @@ -567,14 +567,14 @@ public final class IndexSettings {

public static final Setting<String> INDEX_MERGE_ON_FLUSH_POLICY = Setting.simpleString(
"index.merge_on_flush.policy",
DEFAULT,
DEFAULT_POLICY,
Property.IndexScope,
Property.Dynamic
);

public static final Setting<String> INDEX_MERGE_POLICY = Setting.simpleString("index.merge.policy", DEFAULT, policy -> {
public static final Setting<String> INDEX_MERGE_POLICY = Setting.simpleString("index.merge.policy", DEFAULT_POLICY, policy -> {
if (!(policy.isEmpty()
rishabhmaurya marked this conversation as resolved.
Show resolved Hide resolved
|| policy.equals(DEFAULT)
|| policy.equals(DEFAULT_POLICY)
|| policy.equals(TIERED_MERGE_POLICY)
|| policy.equals(LOG_BYTE_SIZE_MERGE_POLICY))) {
throw new IllegalArgumentException(
Expand All @@ -583,7 +583,7 @@ public final class IndexSettings {
+ " has unsupported policy specified: "
+ policy
+ ". Please use one of: "
+ DEFAULT
+ DEFAULT_POLICY
+ ", "
+ TIERED_MERGE_POLICY
+ ", "
Expand All @@ -594,10 +594,10 @@ public final class IndexSettings {

public static final Setting<String> TIME_INDEX_MERGE_POLICY = Setting.simpleString(
"indices.time_index.default_index_merge_policy",
DEFAULT,
DEFAULT_POLICY,
policy -> {
if (!(policy.isEmpty()
|| policy.equals(DEFAULT)
|| policy.equals(DEFAULT_POLICY)
|| policy.equals(TIERED_MERGE_POLICY)
|| policy.equals(LOG_BYTE_SIZE_MERGE_POLICY))) {
throw new IllegalArgumentException(
Expand All @@ -606,7 +606,7 @@ public final class IndexSettings {
+ " has unsupported policy specified: "
+ policy
+ ". Please use one of: "
+ DEFAULT
+ DEFAULT_POLICY
+ ", "
+ TIERED_MERGE_POLICY
+ ", "
Expand Down Expand Up @@ -1522,7 +1522,7 @@ public MergePolicy getMergePolicy(boolean isTimeIndex) {
mergePolicyProvider = tieredMergePolicyProvider;
} else if (indexScopedPolicy.equals(LOG_BYTE_SIZE_MERGE_POLICY)) {
mergePolicyProvider = logByteSizeMergePolicyProvider;
} else if (indexScopedPolicy.equals(DEFAULT) || Strings.isEmpty(indexScopedPolicy)) {
} else if (indexScopedPolicy.equals(DEFAULT_POLICY) || Strings.isEmpty(indexScopedPolicy)) {
if (!isTimeIndex) {
mergePolicyProvider = tieredMergePolicyProvider;
} else {
Expand All @@ -1531,7 +1531,7 @@ public MergePolicy getMergePolicy(boolean isTimeIndex) {
mergePolicyProvider = tieredMergePolicyProvider;
} else if (nodeScopedTimeIndexPolicy.equals(LOG_BYTE_SIZE_MERGE_POLICY)) {
mergePolicyProvider = logByteSizeMergePolicyProvider;
} else if (nodeScopedTimeIndexPolicy.equals(DEFAULT) || Strings.isEmpty(nodeScopedTimeIndexPolicy)) {
} else if (nodeScopedTimeIndexPolicy.equals(DEFAULT_POLICY) || Strings.isEmpty(nodeScopedTimeIndexPolicy)) {
mergePolicyProvider = tieredMergePolicyProvider;
} else {
throw new IllegalArgumentException(
rishabhmaurya marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -1540,7 +1540,7 @@ public MergePolicy getMergePolicy(boolean isTimeIndex) {
+ " has unsupported policy specified: "
+ nodeScopedTimeIndexPolicy
+ ". Please use one of: "
+ DEFAULT
+ DEFAULT_POLICY
+ ", "
+ TIERED_MERGE_POLICY
+ ", "
Expand All @@ -1555,7 +1555,7 @@ public MergePolicy getMergePolicy(boolean isTimeIndex) {
+ " has unsupported policy specified: "
+ indexScopedPolicy
+ ". Please use one of: "
+ DEFAULT
+ DEFAULT_POLICY
+ ", "
+ TIERED_MERGE_POLICY
+ ", "
Expand Down Expand Up @@ -1756,7 +1756,7 @@ public boolean isMergeOnFlushEnabled() {
}

private void setMergeOnFlushPolicy(String policy) {
if (Strings.isEmpty(policy) || DEFAULT.equalsIgnoreCase(policy)) {
if (Strings.isEmpty(policy) || DEFAULT_POLICY.equalsIgnoreCase(policy)) {
mergeOnFlushPolicy = null;
} else if (MERGE_ON_FLUSH_MERGE_POLICY.equalsIgnoreCase(policy)) {
this.mergeOnFlushPolicy = MergeOnFlushMergePolicy::new;
Expand All @@ -1767,7 +1767,7 @@ private void setMergeOnFlushPolicy(String policy) {
+ " has unsupported policy specified: "
+ policy
+ ". Please use one of: "
+ DEFAULT
+ DEFAULT_POLICY
+ ", "
+ MERGE_ON_FLUSH_MERGE_POLICY
);
Expand Down