Skip to content
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 @@ -82,7 +82,7 @@ public Watch watch() {
return watch;
}

public void ensureWatchExists(CheckedSupplier<Watch, Exception> supplier) throws Exception {
public final void ensureWatchExists(CheckedSupplier<Watch, Exception> supplier) throws Exception {
if (watch == null) {
watch = supplier.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
package org.elasticsearch.xpack.watcher.execution;

import org.elasticsearch.common.CheckedSupplier;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.xpack.core.watcher.actions.Action;
import org.elasticsearch.xpack.core.watcher.actions.ActionWrapper;
Expand All @@ -29,18 +28,19 @@ public class ManualExecutionContext extends WatchExecutionContext {
private final Map<String, ActionExecutionMode> actionModes;
private final boolean recordExecution;
private final boolean knownWatch;
private final Watch watch;

ManualExecutionContext(Watch watch, boolean knownWatch, DateTime executionTime, ManualTriggerEvent triggerEvent,
TimeValue defaultThrottlePeriod, Input.Result inputResult, Condition.Result conditionResult,
Map<String, ActionExecutionMode> actionModes, boolean recordExecution) {
Map<String, ActionExecutionMode> actionModes, boolean recordExecution) throws Exception {

super(watch.id(), executionTime, triggerEvent, defaultThrottlePeriod);

this.actionModes = actionModes;
this.recordExecution = recordExecution;
this.knownWatch = knownWatch;
this.watch = watch;

// set the watch early to ensure calls to watch() below succeed.
super.ensureWatchExists(() -> watch);

if (inputResult != null) {
onInputResult(inputResult);
Expand All @@ -66,12 +66,6 @@ public class ManualExecutionContext extends WatchExecutionContext {
}
}

// a noop operation, as the watch is already loaded via ctor
@Override
public void ensureWatchExists(CheckedSupplier<Watch, Exception> supplier) throws Exception {
super.ensureWatchExists(() -> watch);
}

@Override
public boolean knownWatch() {
return knownWatch;
Expand Down Expand Up @@ -107,11 +101,6 @@ public final boolean recordExecution() {
return recordExecution;
}

@Override
public Watch watch() {
return watch;
}

public static Builder builder(Watch watch, boolean knownWatch, ManualTriggerEvent event, TimeValue defaultThrottlePeriod) {
return new Builder(watch, knownWatch, event, defaultThrottlePeriod);
}
Expand Down Expand Up @@ -173,7 +162,7 @@ public Builder withCondition(Condition.Result conditionResult) {
return this;
}

public ManualExecutionContext build() {
public ManualExecutionContext build() throws Exception {
if (executionTime == null) {
executionTime = DateTime.now(DateTimeZone.UTC);
}
Expand Down