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
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class DBScanEngine extends AbstractClusterEngine {

public static final double DEFAULT_ALPHA = 144.47117699d;
public static final double DEFAULT_BETA = 0.55257784d;
public static final String DEFAULT_DISTANCE_MEASURE = "alarminspaceandtimedistance";
public static final String DEFAULT_DISTANCE_MEASURE = "hellinger";
private final double epsilon;
private final DistanceMeasure distanceMeasure;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<cm:property name="epsilon" value="100"/>
<cm:property name="alpha" value="144.47117699"/>
<cm:property name="beta" value="0.55257784"/>
<cm:property name="distanceMeasure" value="alarmInSpaceAndTimeDistanceMeasureFactory"/>
<cm:property name="distanceMeasure" value="hellinger"/>
</cm:default-properties>
</cm:property-placeholder>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.opennms.alec.engine.dbscan.HellingerDistanceMeasure;
import org.opennms.alec.engine.deeplearning.DeepLearningEngineConf;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

public class EngineParameterImpl implements EngineParameter {
Expand Down Expand Up @@ -124,7 +125,14 @@ public boolean isRemote() {
return remote;
}

/**
* The {@link JsonIgnoreProperties} is intentional: persisted JSON in the
* KV store may contain fields added by future versions (e.g. ALEC-297's
* {@code noPathDistance}) and we must be able to deserialize it instead
* of failing the bundle startup with an "Unrecognized field" error.
*/
@JsonPOJOBuilder(withPrefix = "")
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class Builder {
private Double alpha;
private Double beta;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ public interface EngineRest {
@GET
@Path("/configuration")
Response getEngineConfiguration();

@POST
@Path("/reEvaluate")
Response reEvaluateAllOpenAlarms();
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,24 @@ private Response configureAndStoreDeeplearning(EngineParameter engineParameter,
}
}

@Override
public Response reEvaluateAllOpenAlarms() {
Response failure = driverInit(driver);
if (failure != null) {
return failure;
}
return Response.ok("Engine driver re-initialized; current alarms re-evaluated").build();
}
Comment thread
joseanesONMS marked this conversation as resolved.

private Response driverInit(Driver driver) {
driver.destroy();
CompletableFuture<Void> future = driver.initAsync();
try {
future.get();
} catch (InterruptedException e) {
LOG.error("Engine creation failed", e.getCause());
LOG.error("Engine creation interrupted", e);
Thread.currentThread().interrupt();
return ALECRestUtils.somethingWentWrong(e);
} catch (ExecutionException e) {
LOG.error("Engine creation failed", e.getCause());
return ALECRestUtils.somethingWentWrong(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ public interface SituationRest {

@POST
Response createSituation(CreateSituationPayload createSituationPayload);

@POST
@Path("closeAll")
Response closeAllOpenSituations();
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,33 @@ private Set<Alarm> getAlarmSetToAdd(List<String> alarmIdList) throws Interrupted
return alarms;
}

@Override
public Response closeAllOpenSituations() {
try {
List<Situation> open = situationDatasource.getSituations().stream()
.filter(s -> !Status.REJECTED.equals(s.getStatus())
&& !Status.ACCEPTED.equals(s.getStatus()))
.collect(Collectors.toList());
int closed = 0;
for (Situation situation : open) {
String feedback = String.format("close-all: situation [%d]", situation.getLongId());
situationDatasource.forwardSituation(ImmutableSituation.newBuilderFrom(situation)
.setStatus(Status.REJECTED)
.setAlarms(Collections.emptySet())
.setSeverity(Severity.NORMAL)
.addFeedback(feedback)
.build());
closed++;
}
return Response.ok(MessageFormat.format("Closed {0} open situation(s)", closed)).build();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return ALECRestUtils.somethingWentWrong(e);
} catch (Exception e) {
return ALECRestUtils.somethingWentWrong(e);
}
}

private boolean alarmIsNotInAnotherSituation(String reductionKey) throws InterruptedException {
for (Situation situation : situationDatasource.getSituations()) {
for (Alarm alarm : situation.getAlarms()) {
Expand Down
Loading
Loading