Skip to content

Commit

Permalink
#15: Rules evaluate their enabled/disabled status now
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Geisselmeier committed Sep 18, 2015
1 parent 179d120 commit cb52deb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ protected AbstractNumericRule(T initalLimit, JMXFunction<T> jmxFunction) {
}

public EvaluationResult<T> evaluate(MBeanServerConnection mbsc) {
if (!isEnabled()) {
return new EvaluationResult<T>(HealthStatus.UNKNOW);
}
try {
final T currentValue = jmxFunction.evaluate(mbsc);
if (getLimit().compareTo(currentValue) <= 0) { // i.e. getLimit() <= execTime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.levigo.jadice.server.converterclient.gui.clusterhealth.rule;

import java.util.Objects;
import java.util.Optional;

import org.levigo.jadice.server.converterclient.gui.clusterhealth.HealthStatus;
Expand All @@ -13,6 +14,10 @@ public class EvaluationResult<T> {
public final Optional<T> currentValue;

public final Optional<Throwable> error;

public EvaluationResult(HealthStatus status) {
this(status, Optional.empty(), Optional.empty(), Optional.empty());
}

public EvaluationResult(HealthStatus status, T currentValue) {
this(status, Optional.of(currentValue), Optional.empty(), Optional.empty());
Expand All @@ -27,9 +32,9 @@ public EvaluationResult(HealthStatus status, Throwable error) {
}

private EvaluationResult(HealthStatus status, Optional<T> currentValue, Optional<String> message, Optional<Throwable> error) {
this.status = status;
this.currentValue = currentValue;
this.message = message;
this.error = error;
this.status = Objects.requireNonNull(status, "status must not be null");
this.currentValue = Objects.requireNonNull(currentValue, "currentValue must not be null");
this.message = Objects.requireNonNull(message, "message must not be null");
this.error = Objects.requireNonNull(error, "error must not be null");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public BooleanProperty enabledProperty() {

@Override
public EvaluationResult<Boolean> evaluate(MBeanServerConnection mbsc) {
if (!isEnabled()) {
return new EvaluationResult<>(HealthStatus.UNKNOW);
}
try {
if (JmxHelper.isRunning(mbsc)) {
return new EvaluationResult<Boolean>(HealthStatus.GOOD, true);
Expand Down

0 comments on commit cb52deb

Please sign in to comment.