This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Expose queue rejection time period setting in rca.conf #356
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
40 changes: 40 additions & 0 deletions
40
...zon/opendistro/elasticsearch/performanceanalyzer/rca/configs/QueueRejectionRcaConfig.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,40 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.configs; | ||
|
||
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.core.RcaConf; | ||
|
||
public class QueueRejectionRcaConfig { | ||
private Integer rejectionTimePeriodInSeconds; | ||
public static final int DEFAULT_REJECTION_TIME_PERIOD_IN_SECONDS = 300; | ||
public static final String CONFIG_NAME = "queue-rejection-rca"; | ||
|
||
public QueueRejectionRcaConfig(final RcaConf rcaConf) { | ||
rejectionTimePeriodInSeconds = rcaConf.readRcaConfig( | ||
CONFIG_NAME, RCA_CONF_KEY_CONSTANTS.REJECTION_TIME_PERIOD_IN_SECONDS, Integer.class); | ||
if (rejectionTimePeriodInSeconds == null) { | ||
rejectionTimePeriodInSeconds = DEFAULT_REJECTION_TIME_PERIOD_IN_SECONDS; | ||
} | ||
} | ||
|
||
public int getRejectionTimePeriodInSeconds() { | ||
return rejectionTimePeriodInSeconds; | ||
} | ||
|
||
public static class RCA_CONF_KEY_CONSTANTS { | ||
public static final String REJECTION_TIME_PERIOD_IN_SECONDS = "rejection-time-period-in-seconds"; | ||
} | ||
} |
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
47 changes: 47 additions & 0 deletions
47
...opendistro/elasticsearch/performanceanalyzer/rca/configs/QueueRejectionRcaConfigTest.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,47 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.configs; | ||
|
||
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.core.RcaConf; | ||
import com.amazon.opendistro.elasticsearch.performanceanalyzer.rca.framework.util.RcaConsts; | ||
import java.nio.file.Paths; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class QueueRejectionRcaConfigTest { | ||
|
||
private RcaConf rcaConf; | ||
private RcaConf rcaOldConf; | ||
|
||
@Before | ||
public void init() { | ||
String rcaConfPath = Paths.get(RcaConsts.TEST_CONFIG_PATH, "rca_elected_master.conf").toString(); | ||
String rcaOldConfPath = Paths.get(RcaConsts.TEST_CONFIG_PATH, "rca_master.conf").toString(); | ||
rcaConf = new RcaConf(rcaConfPath); | ||
rcaOldConf = new RcaConf(rcaOldConfPath); | ||
} | ||
|
||
@Test | ||
public void testReadConfig() { | ||
QueueRejectionRcaConfig config = new QueueRejectionRcaConfig(rcaConf); | ||
Assert.assertEquals(400, config.getRejectionTimePeriodInSeconds()); | ||
|
||
QueueRejectionRcaConfig oldConfig = new QueueRejectionRcaConfig(rcaOldConf); | ||
Assert.assertEquals(QueueRejectionRcaConfig.DEFAULT_REJECTION_TIME_PERIOD_IN_SECONDS, | ||
oldConfig.getRejectionTimePeriodInSeconds()); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why it should be in a static inner class of its own ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason is because we might want to add more settings to this RCA in the future so it would be better to keep all consts under the same inner class.