Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix log messages and init progress for the profile API
Browse files Browse the repository at this point in the history
This PR fixes incorrect or unnecessary log messages.  The PR also specifies init progress to use ASCII explicitly.  Otherwise, it is possible we may get unexpected characters.

Testing done:
1. gradle build
  • Loading branch information
kaituo committed Jan 27, 2021
1 parent 852c2af commit 4ad4706
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package com.amazon.opendistroforelasticsearch.ad;

import java.util.Locale;

import com.amazon.opendistroforelasticsearch.ad.model.InitProgressProfile;

public abstract class AbstractProfileRunner {
Expand All @@ -29,7 +31,9 @@ protected InitProgressProfile computeInitProgressProfile(long totalUpdates, long
int neededPoints = (int) (requiredSamples - totalUpdates);
return new InitProgressProfile(
// rounding: 93.456 => 93%, 93.556 => 94%
String.format("%.0f%%", percent),
// Without Locale.US, sometimes conversions use localized decimal digits
// rather than the usual ASCII digits. See https://tinyurl.com/y5sdr5tp
String.format(Locale.US, "%.0f%%", percent),
intervalMins * neededPoints,
neededPoints
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,13 @@ private void getJob(

delegateListener.onResponse(builder.build());
}, exception -> {
logger.warn("fail to get last sample time", exception);
// sth wrong like result index not created. Return what we have
if (exception instanceof IndexNotFoundException) {
// don't print out stack trace since it is not helpful
logger.info("Result index hasn't been created", exception.getMessage());
} else {
logger.warn("fail to get last sample time", exception);
}
delegateListener.onResponse(builder.build());
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected void doExecute(Task task, EntityProfileRequest request, ActionListener
listener.onResponse(builder.build());
} else {
// redirect
LOG.debug("Sending RCF polling request to {} for detector {}, entity {}", nodeId, adID, entityValue);
LOG.debug("Sending entity profile request to {} for detector {}, entity {}", nodeId, adID, entityValue);

try {
transportService
Expand Down

0 comments on commit 4ad4706

Please sign in to comment.