Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

allow non-negative window delay #30

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public class IntervalTimeConfiguration extends TimeConfiguration {
* @param unit time unit
*/
public IntervalTimeConfiguration(long interval, ChronoUnit unit) {
if (interval <= 0) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "Interval %s should be positive", interval));
if (interval < 0) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "Interval %s should be non-negative", interval));
}
if (!SUPPORTED_UNITS.contains(unit)) {
throw new IllegalArgumentException(String.format(Locale.ROOT, "Timezone %s is not supported", unit));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ private AnomalyDetectorSettings() {}
);

public static final Setting<TimeValue> DETECTION_WINDOW_DELAY = Setting
.positiveTimeSetting(
.timeSetting(
"ml.anomaly_detectors.detection_window_delay",
TimeValue.timeValueSeconds(30),
TimeValue.timeValueMinutes(0),
Setting.Property.NodeScope,
Setting.Property.Dynamic
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public void testWrongInterval() throws Exception {
TestHelpers
.assertFailWith(
IllegalArgumentException.class,
"should be positive",
() -> new IntervalTimeConfiguration(randomLongBetween(-100, 0), ChronoUnit.MINUTES)
"should be non-negative",
() -> new IntervalTimeConfiguration(randomLongBetween(-100, -1), ChronoUnit.MINUTES)
);
}

Expand Down