Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/main/java/com/microsoft/dhalion/api/IHealthPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public interface IHealthPolicy {
*/
Collection<Action> executeResolvers(Collection<Diagnosis> diagnosis);

/**
* Invoked in the event that the policy should be overridden, this method executes one {@link IResolver} to fix a
* single identified issue.
*
* @param resolver a resolver to be executed
* @return actions executed to mitigate health issues
*/
Collection<Action> executeResolver(IResolver resolver);

/**
* @return the remaining delay before re-execution of this policy
*/
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/microsoft/dhalion/api/IResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ default Collection<String> getActionTypes() {
default void initialize(ExecutionContext context) {
}

/**
* Triggers execution of {@link Action}s which are expected to improved system health.
*
* @return all the actions executed by this resolver
*/
default Collection<Action> resolve() {
throw new UnsupportedOperationException();
}

/**
* Triggers execution of {@link Action}s which are expected to improved system health.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class EventDispatcher<T> implements EventHandler<T> {

public synchronized void addHandler(EventHandler<T> handler) {
if (handlers.contains(handler)) {
throw new IllegalArgumentException("Duplicate hanlder registration");
throw new IllegalArgumentException("Duplicate handler registration");
}
handlers.add(handler);
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/microsoft/dhalion/policy/HealthPolicyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,24 @@ public Collection<Action> executeResolvers(Collection<Diagnosis> diagnosis) {
return actions;
}

@Override
public Collection<Action> executeResolver(IResolver resolver) {
if (oneTimeDelay != null && !oneTimeDelay.isAfter(clock.now())) {
// reset one time delay timestamp
oneTimeDelay = null;
}

Collection<Action> actions = new ArrayList<>();
if (!resolvers.contains(resolver)) {
return actions;
}

actions = resolver.resolve();

lastExecutionTimestamp = clock.now();
return actions;
}

@Override
public Duration getDelay() {
long delay;
Expand Down