use of org.opensearch.ad.model.InitProgressProfile in project anomaly-detection by opensearch-project.
the class CacheBuffer method equals.
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
if (obj instanceof InitProgressProfile) {
CacheBuffer other = (CacheBuffer) obj;
EqualsBuilder equalsBuilder = new EqualsBuilder();
equalsBuilder.append(detectorId, other.detectorId);
return equalsBuilder.isEquals();
}
return false;
}
use of org.opensearch.ad.model.InitProgressProfile in project anomaly-detection by opensearch-project.
the class EntityProfileRunner method sendRunningState.
private void sendRunningState(Set<EntityProfileName> profilesToCollect, Entity entityValue, MultiResponsesDelegateActionListener<EntityProfile> delegateListener) {
EntityProfile.Builder builder = new EntityProfile.Builder();
if (profilesToCollect.contains(EntityProfileName.STATE)) {
builder.state(EntityState.RUNNING);
}
if (profilesToCollect.contains(EntityProfileName.INIT_PROGRESS)) {
InitProgressProfile initProgress = new InitProgressProfile("100%", 0, 0);
builder.initProgress(initProgress);
}
delegateListener.onResponse(builder.build());
}
use of org.opensearch.ad.model.InitProgressProfile in project anomaly-detection by opensearch-project.
the class AnomalyDetectorProfileRunner method processInitResponse.
private void processInitResponse(AnomalyDetector detector, Set<DetectorProfileName> profilesToCollect, long totalUpdates, boolean hideMinutesLeft, DetectorProfile.Builder builder, MultiResponsesDelegateActionListener<DetectorProfile> listener) {
if (profilesToCollect.contains(DetectorProfileName.STATE)) {
builder.state(DetectorState.INIT);
}
if (profilesToCollect.contains(DetectorProfileName.INIT_PROGRESS)) {
if (hideMinutesLeft) {
InitProgressProfile initProgress = computeInitProgressProfile(totalUpdates, 0);
builder.initProgress(initProgress);
} else {
long intervalMins = ((IntervalTimeConfiguration) detector.getDetectionInterval()).toDuration().toMinutes();
InitProgressProfile initProgress = computeInitProgressProfile(totalUpdates, intervalMins);
builder.initProgress(initProgress);
}
}
listener.onResponse(builder.build());
}
use of org.opensearch.ad.model.InitProgressProfile in project anomaly-detection by opensearch-project.
the class AnomalyDetectorProfileRunnerTests method testInitNoUpdateNoIndex.
public void testInitNoUpdateNoIndex() throws IOException, InterruptedException {
setUpClientGet(DetectorStatus.EXIST, JobStatus.ENABLED, RCFPollingStatus.EMPTY, ErrorResultStatus.NO_ERROR);
DetectorProfile expectedProfile = new DetectorProfile.Builder().state(DetectorState.INIT).initProgress(new InitProgressProfile("0%", detectorIntervalMin * requiredSamples, requiredSamples)).build();
final CountDownLatch inProgressLatch = new CountDownLatch(1);
runner.profile(detector.getDetectorId(), ActionListener.wrap(response -> {
assertEquals(expectedProfile, response);
inProgressLatch.countDown();
}, exception -> {
LOG.error(exception);
for (StackTraceElement ste : exception.getStackTrace()) {
LOG.info(ste);
}
assertTrue("Should not reach here ", false);
inProgressLatch.countDown();
}), stateInitProgress);
assertTrue(inProgressLatch.await(100, TimeUnit.SECONDS));
}
use of org.opensearch.ad.model.InitProgressProfile in project anomaly-detection by opensearch-project.
the class AnomalyDetectorProfileRunnerTests method testInitProgressFailImmediately.
public void testInitProgressFailImmediately() throws IOException, InterruptedException {
setUpClientGet(DetectorStatus.NO_DOC, JobStatus.ENABLED, RCFPollingStatus.INITTING, ErrorResultStatus.NO_ERROR);
DetectorProfile expectedProfile = new DetectorProfile.Builder().state(DetectorState.INIT).build();
// 123 / 128 rounded to 96%
InitProgressProfile profile = new InitProgressProfile("96%", neededSamples * detectorIntervalMin, neededSamples);
expectedProfile.setInitProgress(profile);
final CountDownLatch inProgressLatch = new CountDownLatch(1);
runner.profile(detector.getDetectorId(), ActionListener.wrap(response -> {
assertTrue("Should not reach here ", false);
inProgressLatch.countDown();
}, exception -> {
assertTrue(exception.getMessage().contains(CommonErrorMessages.FAIL_TO_FIND_DETECTOR_MSG));
inProgressLatch.countDown();
}), stateInitProgress);
assertTrue(inProgressLatch.await(100, TimeUnit.SECONDS));
}
Aggregations