This is an automated email from the ASF dual-hosted git repository.
xhsun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 610350a [TE] Retain the original last success task execution time if
we can't… (#5207)
610350a is described below
commit 610350a04b58447a09687ef97cc5fbcf8ebd3b77
Author: Xiaohui Sun <[email protected]>
AuthorDate: Mon Apr 6 11:25:57 2020 -0700
[TE] Retain the original last success task execution time if we can't…
(#5207)
* [TE] Retain the original last success task execution time if we can't
find success tasks
* Revert "[TE] Retain the original last success task execution time if we
can't find success tasks"
This reverts commit a58cfdfe85f51a8f4fb90a0fd383d83bf6e14a6f.
* [TE] keep the last task exeuction time if there is no success task
Co-authored-by: Xiaohui Sun <[email protected]>
---
.../thirdeye/anomaly/monitor/MonitorTaskRunner.java | 1 +
.../thirdeye/detection/health/DetectionHealth.java | 19 +++++++++++++++++--
.../detection/health/DetectionTaskStatus.java | 15 +++++++++------
3 files changed, 27 insertions(+), 8 deletions(-)
diff --git
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/monitor/MonitorTaskRunner.java
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/monitor/MonitorTaskRunner.java
index eb1a81f..545af0a 100644
---
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/monitor/MonitorTaskRunner.java
+++
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/monitor/MonitorTaskRunner.java
@@ -137,6 +137,7 @@ public class MonitorTaskRunner implements TaskRunner {
.addAnomalyCoverageStatus(DAO_REGISTRY.getMergedAnomalyResultDAO())
.addDetectionTaskStatus(DAO_REGISTRY.getTaskDAO())
.addOverallHealth()
+ .addOriginalDetectionHealth(config.getHealth())
.build();
// fetch the config again before saving to DB to avoid overriding
config that is updated by other threads
config = detectionDAO.findById(config.getId());
diff --git
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionHealth.java
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionHealth.java
index f393cb8..ed82f24 100644
---
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionHealth.java
+++
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionHealth.java
@@ -97,6 +97,8 @@ public class DetectionHealth {
private long taskLimit;
private boolean provideOverallHealth;
+ private DetectionHealth lastDetectionHealth;
+
// database column name constants
private static String COL_NAME_START_TIME = "startTime";
private static String COL_NAME_END_TIME = "endTime";
@@ -166,6 +168,15 @@ public class DetectionHealth {
}
/**
+ * Add the original detection health. This is needed since we need to keep
the last task success time.
+ * @return the builder
+ */
+ public Builder addOriginalDetectionHealth(DetectionHealth
lastDetectionHealth) {
+ this.lastDetectionHealth = lastDetectionHealth;
+ return this;
+ }
+
+ /**
* Build the health status object
* @return the health status object
*/
@@ -244,7 +255,11 @@ public class DetectionHealth {
Predicate.IN(COL_NAME_TASK_STATUS, new
String[]{TaskConstants.TaskStatus.COMPLETED.toString(),
TaskConstants.TaskStatus.FAILED.toString(),
TaskConstants.TaskStatus.TIMEOUT.toString(),
TaskConstants.TaskStatus.WAITING.toString()})));
- return DetectionTaskStatus.fromTasks(tasks, this.taskLimit);
+ long lastTaskExecutionTime = -1L;
+ if (lastDetectionHealth != null &&
lastDetectionHealth.getDetectionTaskStatus() != null) {
+ lastTaskExecutionTime =
lastDetectionHealth.getDetectionTaskStatus().getLastTaskExecutionTime();
+ }
+ return DetectionTaskStatus.fromTasks(tasks, lastTaskExecutionTime,
this.taskLimit);
}
private static HealthStatus classifyOverallHealth(DetectionHealth health) {
@@ -277,7 +292,7 @@ public class DetectionHealth {
public static DetectionHealth unknown() {
DetectionHealth health = new DetectionHealth();
health.anomalyCoverageStatus =
AnomalyCoverageStatus.fromCoverageRatio(Double.NaN);
- health.detectionTaskStatus =
DetectionTaskStatus.fromTasks(Collections.emptyList());
+ health.detectionTaskStatus =
DetectionTaskStatus.fromTasks(Collections.emptyList(), -1L);
health.regressionStatus =
RegressionStatus.fromDetectorMapes(Collections.emptyMap());
health.overallHealth = HealthStatus.UNKNOWN;
return health;
diff --git
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionTaskStatus.java
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionTaskStatus.java
index 3f682cc..2c4ee70 100644
---
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionTaskStatus.java
+++
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/health/DetectionTaskStatus.java
@@ -100,32 +100,35 @@ public class DetectionTaskStatus {
return taskCounts;
}
- public static DetectionTaskStatus fromTasks(List<TaskDTO> tasks) {
+ public static DetectionTaskStatus fromTasks(List<TaskDTO> tasks, long
lastTaskExecutionTime) {
// count the number of tasks by task status
tasks.sort(Comparator.comparingLong(TaskBean::getStartTime).reversed());
Map<TaskConstants.TaskStatus, Long> counts =
tasks.stream().collect(Collectors.groupingBy(TaskBean::getStatus,
Collectors.counting()));
double taskSuccessRate = getTaskSuccessRate(counts);
- long lastTaskExecutionTime = getLastSuccessTaskExecutionTime(tasks);
- return new DetectionTaskStatus(taskSuccessRate,
classifyTaskStatus(taskSuccessRate), counts, tasks, lastTaskExecutionTime);
+ long newTaskExecutionTime = getLastSuccessTaskExecutionTime(tasks);
+ newTaskExecutionTime = newTaskExecutionTime == -1L ? lastTaskExecutionTime
: newTaskExecutionTime;
+ return new DetectionTaskStatus(taskSuccessRate,
classifyTaskStatus(taskSuccessRate), counts, tasks, newTaskExecutionTime);
}
/**
* Create a Detection task status from a list of tasks
* @param tasks the list of tasks
+ * @param lastTaskExecutionTime the last task exeuction time
* @param taskLimit the number of tasks should be returned in the task status
* @return the DetectionTaskStatus
*/
- public static DetectionTaskStatus fromTasks(List<TaskDTO> tasks, long
taskLimit) {
+ public static DetectionTaskStatus fromTasks(List<TaskDTO> tasks, long
lastTaskExecutionTime, long taskLimit) {
// count the number of tasks by task status
tasks.sort(Comparator.comparingLong(TaskBean::getStartTime).reversed());
Map<TaskConstants.TaskStatus, Long> counts =
tasks.stream().collect(Collectors.groupingBy(TaskBean::getStatus,
Collectors.counting()));
double taskSuccessRate = getTaskSuccessRate(counts);
- long lastTaskExecutionTime = getLastSuccessTaskExecutionTime(tasks);
+ long newTaskExecutionTime = getLastSuccessTaskExecutionTime(tasks);
+ newTaskExecutionTime = newTaskExecutionTime == -1L ? lastTaskExecutionTime
: newTaskExecutionTime;
tasks = tasks.stream().limit(taskLimit).collect(Collectors.toList());
return new DetectionTaskStatus(taskSuccessRate,
classifyTaskStatus(taskSuccessRate), counts, tasks,
- lastTaskExecutionTime);
+ newTaskExecutionTime);
}
private static Long getLastSuccessTaskExecutionTime(List<TaskDTO> tasks) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]