From 88e88efa13fea4b0f6c60d5f1d5abc815d5c48bf Mon Sep 17 00:00:00 2001 From: Kaituo Li Date: Thu, 12 Sep 2024 14:02:09 -0700 Subject: [PATCH] fix bug Signed-off-by: Kaituo Li --- src/main/java/org/opensearch/ad/model/AnomalyResult.java | 8 ++++---- .../org/opensearch/forecast/model/ForecastResult.java | 4 ++-- .../opensearch/timeseries/transport/ResultProcessor.java | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/opensearch/ad/model/AnomalyResult.java b/src/main/java/org/opensearch/ad/model/AnomalyResult.java index 868317bab..780e2f102 100644 --- a/src/main/java/org/opensearch/ad/model/AnomalyResult.java +++ b/src/main/java/org/opensearch/ad/model/AnomalyResult.java @@ -93,7 +93,7 @@ public class AnomalyResult extends IndexableResult { pastValues is related to relativeIndex, startOfAnomaly and anomaly grade. So if we detect anomaly late, we get the baseDimension values from the past (current is 0). That is, we look back relativeIndex * baseDimensions. - + For example, current shingle is "currentValues": [ 6819.0, @@ -145,10 +145,10 @@ So if we detect anomaly late, we get the baseDimension values from the past (cur 86376.0, 64878.0 ], - + So pastValues is null when relativeIndex is 0 or startOfAnomaly is true or the current shingle is not an anomaly. - + In the UX, if pastValues value is null, we can just show attribution/expected value and it is implicit this is due to current input; if pastValues is not null, it means the the attribution/expected values are from an old value @@ -446,7 +446,7 @@ public static AnomalyResult fromRawTRCFResult( taskId, rcfScore, Math.max(0, grade), - confidence, + Math.min(1, confidence), featureData, dataStartTime, dataEndTime, diff --git a/src/main/java/org/opensearch/forecast/model/ForecastResult.java b/src/main/java/org/opensearch/forecast/model/ForecastResult.java index 69dd4d6ea..49f51e2e9 100644 --- a/src/main/java/org/opensearch/forecast/model/ForecastResult.java +++ b/src/main/java/org/opensearch/forecast/model/ForecastResult.java @@ -188,7 +188,7 @@ public static List fromRawRCFCasterResult( new ForecastResult( forecasterId, taskId, - dataQuality, + Math.min(1, dataQuality), featureData, dataStartTime, dataEndTime, @@ -218,7 +218,7 @@ public static List fromRawRCFCasterResult( new ForecastResult( forecasterId, taskId, - dataQuality, + Math.min(1, dataQuality), null, dataStartTime, dataEndTime, diff --git a/src/main/java/org/opensearch/timeseries/transport/ResultProcessor.java b/src/main/java/org/opensearch/timeseries/transport/ResultProcessor.java index b244ee4ac..40fe82462 100644 --- a/src/main/java/org/opensearch/timeseries/transport/ResultProcessor.java +++ b/src/main/java/org/opensearch/timeseries/transport/ResultProcessor.java @@ -229,8 +229,6 @@ public void onResponse(CompositeRetriever.Page entityFeatures) { pageIterator.next(this); } if (entityFeatures != null && false == entityFeatures.isEmpty()) { - sentOutPages.incrementAndGet(); - LOG .info( "Sending an HC request to process data from timestamp {} to {} for config {}", @@ -285,6 +283,7 @@ public void onResponse(CompositeRetriever.Page entityFeatures) { final AtomicReference failure = new AtomicReference<>(); node2Entities.stream().forEach(nodeEntity -> { + sentOutPages.incrementAndGet(); DiscoveryNode node = nodeEntity.getKey(); transportService .sendRequest( @@ -370,7 +369,7 @@ public void run() { cancellable.get().cancel(); } } else if (Instant.now().toEpochMilli() >= timeoutMillis) { - LOG.warn("Scheduled impute HC task is cancelled due to timeout"); + LOG.warn("Scheduled impute HC task is cancelled due to timeout, current epoch {}, timeout epoch {}, dataEndTime {}, sent out {}, receive {}", Instant.now().toEpochMilli(), timeoutMillis, dataEndTime, sentOutPages.get(), receivedPages.get()); if (cancellable != null) { cancellable.get().cancel(); }