use of org.opensearch.ad.transport.AnomalyResultRequest in project anomaly-detection by opensearch-project.
the class AnomalyDetectorJobRunner method runAnomalyDetectionJob.
private void runAnomalyDetectionJob(AnomalyDetectorJob jobParameter, LockService lockService, LockModel lock, Instant detectionStartTime, Instant executionStartTime, String detectorId, String user, List<String> roles) {
try (InjectSecurity injectSecurity = new InjectSecurity(detectorId, settings, client.threadPool().getThreadContext())) {
// Injecting user role to verify if the user has permissions for our API.
injectSecurity.inject(user, roles);
AnomalyResultRequest request = new AnomalyResultRequest(detectorId, detectionStartTime.toEpochMilli(), executionStartTime.toEpochMilli());
client.execute(AnomalyResultAction.INSTANCE, request, ActionListener.wrap(response -> {
indexAnomalyResult(jobParameter, lockService, lock, detectionStartTime, executionStartTime, response);
}, exception -> {
handleAdException(jobParameter, lockService, lock, detectionStartTime, executionStartTime, exception);
}));
} catch (Exception e) {
indexAnomalyResultException(jobParameter, lockService, lock, detectionStartTime, executionStartTime, e, true);
log.error("Failed to execute AD job " + detectorId, e);
}
}
Aggregations