Skip to content

Commit

Permalink
Refactor abstracta#3 Long identifier, changed getter and setter names…
Browse files Browse the repository at this point in the history
… along with constant property value. Updated its usages
  • Loading branch information
alexivimeydal committed Jul 12, 2024
1 parent 98e2bbd commit b9de36a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ protected AggregatedConditionBuilder(AutoStopConditionElement ret,
* @return a condition builder to complete the condition definition.
*/
public AggregatedConditionBuilder<T> every(Duration period) {
ret.setAggregationResetPeriodSeconds(period.getSeconds());
ret.setResetPeriodSeconds(period.getSeconds());
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AutoStopConditionElement extends AbstractTestElement {
private static final String METRIC_PROP = "metric";
private static final String AGGREGATION_PROP = "aggregation";
private static final String PERCENTILE_PROP = "percentile";
private static final String AGGREGATION_RESET_PERIOD_SECONDS_PROP =
private static final String RESET_PERIOD_SECONDS_PROP =
"aggregationResetPeriodSeconds";
private static final String COMPARISON_PROP = "comparison";
private static final String VALUE_PROP = "value";
Expand Down Expand Up @@ -60,12 +60,12 @@ public void setPercentile(double percentile) {
setProperty(new DoubleProperty(PERCENTILE_PROP, percentile));
}

public long getAggregationResetPeriodSeconds() {
return getPropertyAsLong(AGGREGATION_RESET_PERIOD_SECONDS_PROP);
public long getResetPeriodSeconds() {
return getPropertyAsLong(RESET_PERIOD_SECONDS_PROP);
}

public void setAggregationResetPeriodSeconds(long aggregationResetPeriod) {
setProperty(AGGREGATION_RESET_PERIOD_SECONDS_PROP, aggregationResetPeriod);
public void setResetPeriodSeconds(long aggregationResetPeriod) {
setProperty(RESET_PERIOD_SECONDS_PROP, aggregationResetPeriod);
}

public String getComparison() {
Expand Down Expand Up @@ -124,7 +124,7 @@ public boolean eval(SampleResult result) {
if (getRegex() != null && !result.getSampleLabel().matches(getRegex())) {
return false;
}
return getAggregationResetPeriodSeconds() == 0 ? isMatchNow(result) : isMatchSlot(result);
return getResetPeriodSeconds() == 0 ? isMatchNow(result) : isMatchSlot(result);
}

private boolean isMatchNow(SampleResult result) {
Expand Down Expand Up @@ -160,7 +160,7 @@ private Duration getHoldsForDuration() {
private boolean isMatchSlot(SampleResult result) {
Instant currentSlotStart = findSlotStart();
while (!slotStart.equals(currentSlotStart)) {
Instant slotEnd = slotStart.plusSeconds(getAggregationResetPeriodSeconds());
Instant slotEnd = slotStart.plusSeconds(getResetPeriodSeconds());
if (isMatchAt(slotEnd)) {
return true;
}
Expand All @@ -173,7 +173,7 @@ private boolean isMatchSlot(SampleResult result) {

private Instant findSlotStart() {
long startMillis = slotStart.toEpochMilli();
long slotMillis = getAggregationResetPeriodSeconds() * 1000;
long slotMillis = getResetPeriodSeconds() * 1000;
long nowMillis = clock.instant().toEpochMilli();
return slotStart.plusMillis(((nowMillis - startMillis) / slotMillis) * slotMillis);
}
Expand Down

0 comments on commit b9de36a

Please sign in to comment.