-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the alert internal model (#382)
- Updates the fields in the Alert model - Rips out all code related to the creation and evaluation of alerts in the previous form. For the latter change in particular, I figured that there wasn't much value in keeping the existing data and view layers around with this change in place since the interface additions would propagate into those layers and I don't intend on supporting them now anyway.
- Loading branch information
Showing
31 changed files
with
437 additions
and
3,514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright 2020 Dropbox, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.arpnetworking.metrics.portal.alerts; | ||
|
||
import com.arpnetworking.metrics.portal.scheduling.Schedule; | ||
import com.arpnetworking.metrics.portal.scheduling.impl.NeverSchedule; | ||
import com.google.inject.Injector; | ||
import models.internal.alerts.Alert; | ||
import models.internal.alerts.AlertEvaluationResult; | ||
import models.internal.scheduling.Job; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
|
||
/** | ||
* A wrapper around {@code Alert} instances to allow for scheduling and evaluation of Alert queries. | ||
* | ||
* @author Christian Briones (cbriones at dropbox dot com) | ||
*/ | ||
public class AlertJob implements Job<AlertEvaluationResult> { | ||
private final Alert _alert; | ||
|
||
/** | ||
* Create a job from an alert. | ||
* | ||
* @param alert The alert that this job will evaluate. | ||
*/ | ||
public AlertJob(final Alert alert) { | ||
this._alert = alert; | ||
} | ||
|
||
@Override | ||
public UUID getId() { | ||
return _alert.getId(); | ||
} | ||
|
||
@Override | ||
public Optional<String> getETag() { | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Schedule getSchedule() { | ||
// TODO(cbriones): If the alert is enabled, this should return an interval corresponding to the smallest query period | ||
// in that alert's query. | ||
return NeverSchedule.getInstance(); | ||
} | ||
|
||
@Override | ||
public Duration getTimeout() { | ||
return Duration.of(1, ChronoUnit.MINUTES); | ||
} | ||
|
||
@Override | ||
public CompletionStage<? extends AlertEvaluationResult> execute(final Injector injector, final Instant scheduled) { | ||
final CompletableFuture<AlertEvaluationResult> future = new CompletableFuture<>(); | ||
future.completeExceptionally(new UnsupportedOperationException("Alert execution is not implemented")); | ||
return future; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
266 changes: 0 additions & 266 deletions
266
app/com/arpnetworking/metrics/portal/alerts/impl/CassandraAlertRepository.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.