Search in sources :

Example 11 with GetRequest

use of org.opensearch.action.get.GetRequest in project anomaly-detection by opensearch-project.

the class ParseUtils method getDetector.

/**
 * If filterByEnabled is true, get detector and check if the user has permissions to access the detector,
 * then execute function; otherwise, get detector and execute function
 * @param requestUser user from request
 * @param detectorId detector id
 * @param listener action listener
 * @param function consumer function
 * @param client client
 * @param clusterService cluster service
 * @param xContentRegistry XContent registry
 * @param filterByBackendRole filter by backend role or not
 */
public static void getDetector(User requestUser, String detectorId, ActionListener listener, Consumer<AnomalyDetector> function, Client client, ClusterService clusterService, NamedXContentRegistry xContentRegistry, boolean filterByBackendRole) {
    if (clusterService.state().metadata().indices().containsKey(AnomalyDetector.ANOMALY_DETECTORS_INDEX)) {
        GetRequest request = new GetRequest(AnomalyDetector.ANOMALY_DETECTORS_INDEX).id(detectorId);
        client.get(request, ActionListener.wrap(response -> onGetAdResponse(response, requestUser, detectorId, listener, function, xContentRegistry, filterByBackendRole), exception -> {
            logger.error("Failed to get anomaly detector: " + detectorId, exception);
            listener.onFailure(exception);
        }));
    } else {
        listener.onFailure(new IndexNotFoundException(AnomalyDetector.ANOMALY_DETECTORS_INDEX));
    }
}
Also used : Max(org.opensearch.search.aggregations.metrics.Max) ResourceNotFoundException(org.opensearch.ad.common.exception.ResourceNotFoundException) BaseAggregationBuilder(org.opensearch.search.aggregations.BaseAggregationBuilder) FAIL_TO_GET_USER_INFO(org.opensearch.ad.constant.CommonErrorMessages.FAIL_TO_GET_USER_INFO) FAIL_TO_FIND_DETECTOR_MSG(org.opensearch.ad.constant.CommonErrorMessages.FAIL_TO_FIND_DETECTOR_MSG) PipelineAggregationBuilder(org.opensearch.search.aggregations.PipelineAggregationBuilder) AnomalyDetectionException(org.opensearch.ad.common.exception.AnomalyDetectionException) XContentParser(org.opensearch.common.xcontent.XContentParser) AggregationBuilder(org.opensearch.search.aggregations.AggregationBuilder) Matcher(java.util.regex.Matcher) DateHistogramValuesSourceBuilder(org.opensearch.search.aggregations.bucket.composite.DateHistogramValuesSourceBuilder) Map(java.util.Map) ActionListener(org.opensearch.action.ActionListener) DateRangeAggregationBuilder(org.opensearch.search.aggregations.bucket.range.DateRangeAggregationBuilder) GetResponse(org.opensearch.action.get.GetResponse) ParsingException(org.opensearch.common.ParsingException) NestedQueryBuilder(org.opensearch.index.query.NestedQueryBuilder) Client(org.opensearch.client.Client) Collection(java.util.Collection) Feature(org.opensearch.ad.model.Feature) QUERY_PARAM_PERIOD_END(org.opensearch.ad.model.AnomalyDetector.QUERY_PARAM_PERIOD_END) LoggingDeprecationHandler(org.opensearch.common.xcontent.LoggingDeprecationHandler) Set(java.util.Set) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) Instant(java.time.Instant) ScoreMode(org.apache.lucene.search.join.ScoreMode) Objects(java.util.Objects) NO_PERMISSION_TO_ACCESS_DETECTOR(org.opensearch.ad.constant.CommonErrorMessages.NO_PERMISSION_TO_ACCESS_DETECTOR) List(java.util.List) Logger(org.apache.logging.log4j.Logger) QueryBuilder(org.opensearch.index.query.QueryBuilder) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) Entry(java.util.Map.Entry) DATE_HISTOGRAM(org.opensearch.ad.constant.CommonName.DATE_HISTOGRAM) Optional(java.util.Optional) TermsQueryBuilder(org.opensearch.index.query.TermsQueryBuilder) FEATURE_AGGS(org.opensearch.ad.constant.CommonName.FEATURE_AGGS) XContentType(org.opensearch.common.xcontent.XContentType) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) ConfigConstants(org.opensearch.commons.ConfigConstants) AggregatorFactories(org.opensearch.search.aggregations.AggregatorFactories) FeatureData(org.opensearch.ad.model.FeatureData) DoubleArrayList(com.carrotsearch.hppc.DoubleArrayList) DateHistogramInterval(org.opensearch.search.aggregations.bucket.histogram.DateHistogramInterval) ArrayList(java.util.ArrayList) CompositeAggregationBuilder(org.opensearch.search.aggregations.bucket.composite.CompositeAggregationBuilder) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) EPOCH_MILLIS_FORMAT(org.opensearch.ad.constant.CommonName.EPOCH_MILLIS_FORMAT) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) SearchResponse(org.opensearch.action.search.SearchResponse) MAX_BATCH_TASK_PIECE_SIZE(org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_BATCH_TASK_PIECE_SIZE) GetAnomalyDetectorResponse(org.opensearch.ad.transport.GetAnomalyDetectorResponse) QueryBuilders(org.opensearch.index.query.QueryBuilders) CommonName(org.opensearch.ad.constant.CommonName) RangeQueryBuilder(org.opensearch.index.query.RangeQueryBuilder) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) GetRequest(org.opensearch.action.get.GetRequest) TermQueryBuilder(org.opensearch.index.query.TermQueryBuilder) IOException(java.io.IOException) Consumer(java.util.function.Consumer) CompositeValuesSourceBuilder(org.opensearch.search.aggregations.bucket.composite.CompositeValuesSourceBuilder) VALID_AGG_NAME(org.opensearch.search.aggregations.AggregatorFactories.VALID_AGG_NAME) Entity(org.opensearch.ad.model.Entity) AggregationBuilders.dateRange(org.opensearch.search.aggregations.AggregationBuilders.dateRange) User(org.opensearch.commons.authuser.User) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) ClusterService(org.opensearch.cluster.service.ClusterService) IntervalTimeConfiguration(org.opensearch.ad.model.IntervalTimeConfiguration) LogManager(org.apache.logging.log4j.LogManager) QUERY_PARAM_PERIOD_START(org.opensearch.ad.model.AnomalyDetector.QUERY_PARAM_PERIOD_START) GetRequest(org.opensearch.action.get.GetRequest) IndexNotFoundException(org.opensearch.index.IndexNotFoundException)

Example 12 with GetRequest

use of org.opensearch.action.get.GetRequest in project anomaly-detection by opensearch-project.

the class IndexAnomalyDetectorActionHandlerTests method testUpdateTemplate.

@SuppressWarnings("unchecked")
private void testUpdateTemplate(String fieldTypeName) throws IOException {
    String field = "a";
    AnomalyDetector detector = TestHelpers.randomAnomalyDetectorUsingCategoryFields(detectorId, Arrays.asList(field));
    SearchResponse detectorResponse = mock(SearchResponse.class);
    int totalHits = 9;
    when(detectorResponse.getHits()).thenReturn(TestHelpers.createSearchHits(totalHits));
    GetResponse getDetectorResponse = TestHelpers.createGetResponse(detector, detector.getDetectorId(), AnomalyDetector.ANOMALY_DETECTORS_INDEX);
    SearchResponse userIndexResponse = mock(SearchResponse.class);
    int userIndexHits = 0;
    when(userIndexResponse.getHits()).thenReturn(TestHelpers.createSearchHits(userIndexHits));
    // extend NodeClient since its execute method is final and mockito does not allow to mock final methods
    // we can also use spy to overstep the final methods
    NodeClient client = new NodeClient(Settings.EMPTY, threadPool) {

        @Override
        public <Request extends ActionRequest, Response extends ActionResponse> void doExecute(ActionType<Response> action, Request request, ActionListener<Response> listener) {
            try {
                if (action.equals(SearchAction.INSTANCE)) {
                    assertTrue(request instanceof SearchRequest);
                    SearchRequest searchRequest = (SearchRequest) request;
                    if (searchRequest.indices()[0].equals(ANOMALY_DETECTORS_INDEX)) {
                        listener.onResponse((Response) detectorResponse);
                    } else {
                        listener.onResponse((Response) userIndexResponse);
                    }
                } else if (action.equals(GetAction.INSTANCE)) {
                    assertTrue(request instanceof GetRequest);
                    listener.onResponse((Response) getDetectorResponse);
                } else {
                    GetFieldMappingsResponse response = new GetFieldMappingsResponse(TestHelpers.createFieldMappings(detector.getIndices().get(0), field, fieldTypeName));
                    listener.onResponse((Response) response);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    };
    NodeClient clientSpy = spy(client);
    ClusterName clusterName = new ClusterName("test");
    ClusterState clusterState = ClusterState.builder(clusterName).metadata(Metadata.builder().build()).build();
    when(clusterService.state()).thenReturn(clusterState);
    handler = new IndexAnomalyDetectorActionHandler(clusterService, clientSpy, transportService, channel, anomalyDetectionIndices, detectorId, seqNo, primaryTerm, refreshPolicy, detector, requestTimeout, maxSingleEntityAnomalyDetectors, maxMultiEntityAnomalyDetectors, maxAnomalyFeatures, RestRequest.Method.PUT, xContentRegistry(), null, adTaskManager, searchFeatureDao);
    ArgumentCaptor<Exception> response = ArgumentCaptor.forClass(Exception.class);
    handler.start();
    verify(clientSpy, times(1)).execute(eq(GetFieldMappingsAction.INSTANCE), any(), any());
    verify(channel).onFailure(response.capture());
    Exception value = response.getValue();
    if (fieldTypeName.equals(CommonName.IP_TYPE) || fieldTypeName.equals(CommonName.KEYWORD_TYPE)) {
        assertTrue(value.getMessage().contains(IndexAnomalyDetectorActionHandler.NO_DOCS_IN_USER_INDEX_MSG));
    } else {
        assertTrue(value.getMessage().contains(IndexAnomalyDetectorActionHandler.CATEGORICAL_FIELD_TYPE_ERR_MSG));
    }
}
Also used : SearchRequest(org.opensearch.action.search.SearchRequest) ClusterState(org.opensearch.cluster.ClusterState) NodeClient(org.opensearch.client.node.NodeClient) ActionType(org.opensearch.action.ActionType) ActionRequest(org.opensearch.action.ActionRequest) WriteRequest(org.opensearch.action.support.WriteRequest) SearchRequest(org.opensearch.action.search.SearchRequest) RestRequest(org.opensearch.rest.RestRequest) GetRequest(org.opensearch.action.get.GetRequest) IOException(java.io.IOException) GetResponse(org.opensearch.action.get.GetResponse) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) ActionResponse(org.opensearch.action.ActionResponse) ADValidationException(org.opensearch.ad.common.exception.ADValidationException) IOException(java.io.IOException) SearchResponse(org.opensearch.action.search.SearchResponse) ActionResponse(org.opensearch.action.ActionResponse) GetResponse(org.opensearch.action.get.GetResponse) IndexAnomalyDetectorResponse(org.opensearch.ad.transport.IndexAnomalyDetectorResponse) SearchResponse(org.opensearch.action.search.SearchResponse) ActionListener(org.opensearch.action.ActionListener) ActionRequest(org.opensearch.action.ActionRequest) GetRequest(org.opensearch.action.get.GetRequest) ClusterName(org.opensearch.cluster.ClusterName) IndexAnomalyDetectorActionHandler(org.opensearch.ad.rest.handler.IndexAnomalyDetectorActionHandler)

Example 13 with GetRequest

use of org.opensearch.action.get.GetRequest in project anomaly-detection by opensearch-project.

the class EntityColdStarterTests method setUp.

@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception {
    super.setUp();
    numMinSamples = AnomalyDetectorSettings.NUM_MIN_SAMPLES;
    clock = mock(Clock.class);
    when(clock.instant()).thenReturn(Instant.now());
    threadPool = mock(ThreadPool.class);
    setUpADThreadPool(threadPool);
    settings = Settings.EMPTY;
    Client client = mock(Client.class);
    clientUtil = mock(ClientUtil.class);
    detector = TestHelpers.AnomalyDetectorBuilder.newInstance().setDetectionInterval(new IntervalTimeConfiguration(1, ChronoUnit.MINUTES)).setCategoryFields(ImmutableList.of(randomAlphaOfLength(5))).build();
    job = TestHelpers.randomAnomalyDetectorJob(true, Instant.ofEpochMilli(1602401500000L), null);
    doAnswer(invocation -> {
        GetRequest request = invocation.getArgument(0);
        ActionListener<GetResponse> listener = invocation.getArgument(2);
        if (request.index().equals(AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX)) {
            listener.onResponse(TestHelpers.createGetResponse(job, detectorId, AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX));
        } else {
            listener.onResponse(TestHelpers.createGetResponse(detector, detectorId, AnomalyDetector.ANOMALY_DETECTORS_INDEX));
        }
        return null;
    }).when(clientUtil).asyncRequest(any(GetRequest.class), any(), any(ActionListener.class));
    Set<Setting<?>> nodestateSetting = new HashSet<>(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
    nodestateSetting.add(MAX_RETRY_FOR_UNRESPONSIVE_NODE);
    nodestateSetting.add(BACKOFF_MINUTES);
    ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, nodestateSetting);
    DiscoveryNode discoveryNode = new DiscoveryNode("node1", OpenSearchTestCase.buildNewFakeTransportAddress(), Collections.emptyMap(), DiscoveryNodeRole.BUILT_IN_ROLES, Version.CURRENT);
    ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool, discoveryNode, clusterSettings);
    stateManager = new NodeStateManager(client, xContentRegistry(), settings, clientUtil, clock, AnomalyDetectorSettings.HOURLY_MAINTENANCE, clusterService);
    SingleFeatureLinearUniformInterpolator singleFeatureLinearUniformInterpolator = new IntegerSensitiveSingleFeatureLinearUniformInterpolator();
    interpolator = new LinearUniformInterpolator(singleFeatureLinearUniformInterpolator);
    searchFeatureDao = mock(SearchFeatureDao.class);
    checkpoint = mock(CheckpointDao.class);
    featureManager = new FeatureManager(searchFeatureDao, interpolator, clock, AnomalyDetectorSettings.MAX_TRAIN_SAMPLE, AnomalyDetectorSettings.MAX_SAMPLE_STRIDE, AnomalyDetectorSettings.TRAIN_SAMPLE_TIME_RANGE_IN_HOURS, AnomalyDetectorSettings.MIN_TRAIN_SAMPLES, AnomalyDetectorSettings.MAX_SHINGLE_PROPORTION_MISSING, AnomalyDetectorSettings.MAX_IMPUTATION_NEIGHBOR_DISTANCE, AnomalyDetectorSettings.PREVIEW_SAMPLE_RATE, AnomalyDetectorSettings.MAX_PREVIEW_SAMPLES, AnomalyDetectorSettings.HOURLY_MAINTENANCE, threadPool, AnomalyDetectorPlugin.AD_THREAD_POOL_NAME);
    checkpointWriteQueue = mock(CheckpointWriteWorker.class);
    rcfSeed = 2051L;
    entityColdStarter = new EntityColdStarter(clock, threadPool, stateManager, AnomalyDetectorSettings.NUM_SAMPLES_PER_TREE, AnomalyDetectorSettings.NUM_TREES, AnomalyDetectorSettings.TIME_DECAY, numMinSamples, AnomalyDetectorSettings.MAX_SAMPLE_STRIDE, AnomalyDetectorSettings.MAX_TRAIN_SAMPLE, interpolator, searchFeatureDao, AnomalyDetectorSettings.THRESHOLD_MIN_PVALUE, featureManager, settings, AnomalyDetectorSettings.HOURLY_MAINTENANCE, checkpointWriteQueue, rcfSeed, AnomalyDetectorSettings.MAX_COLD_START_ROUNDS);
    detectorId = "123";
    modelId = "123_entity_abc";
    entityName = "abc";
    priority = 0.3f;
    entity = Entity.createSingleAttributeEntity("field", entityName);
    released = new AtomicBoolean();
    inProgressLatch = new CountDownLatch(1);
    releaseSemaphore = () -> {
        released.set(true);
        inProgressLatch.countDown();
    };
    listener = ActionListener.wrap(releaseSemaphore);
    modelManager = new ModelManager(mock(CheckpointDao.class), mock(Clock.class), AnomalyDetectorSettings.NUM_TREES, AnomalyDetectorSettings.NUM_SAMPLES_PER_TREE, AnomalyDetectorSettings.TIME_DECAY, AnomalyDetectorSettings.NUM_MIN_SAMPLES, AnomalyDetectorSettings.THRESHOLD_MIN_PVALUE, AnomalyDetectorSettings.MIN_PREVIEW_SIZE, AnomalyDetectorSettings.HOURLY_MAINTENANCE, AnomalyDetectorSettings.HOURLY_MAINTENANCE, entityColdStarter, mock(FeatureManager.class), mock(MemoryTracker.class));
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) ClusterSettings(org.opensearch.common.settings.ClusterSettings) ClientUtil(org.opensearch.ad.util.ClientUtil) ThreadPool(org.opensearch.threadpool.ThreadPool) IntervalTimeConfiguration(org.opensearch.ad.model.IntervalTimeConfiguration) SearchFeatureDao(org.opensearch.ad.feature.SearchFeatureDao) Clock(java.time.Clock) NodeStateManager(org.opensearch.ad.NodeStateManager) IntegerSensitiveSingleFeatureLinearUniformInterpolator(org.opensearch.ad.dataprocessor.IntegerSensitiveSingleFeatureLinearUniformInterpolator) GetRequest(org.opensearch.action.get.GetRequest) SingleFeatureLinearUniformInterpolator(org.opensearch.ad.dataprocessor.SingleFeatureLinearUniformInterpolator) IntegerSensitiveSingleFeatureLinearUniformInterpolator(org.opensearch.ad.dataprocessor.IntegerSensitiveSingleFeatureLinearUniformInterpolator) LinearUniformInterpolator(org.opensearch.ad.dataprocessor.LinearUniformInterpolator) Client(org.opensearch.client.Client) FeatureManager(org.opensearch.ad.feature.FeatureManager) HashSet(java.util.HashSet) Setting(org.opensearch.common.settings.Setting) CountDownLatch(java.util.concurrent.CountDownLatch) GetResponse(org.opensearch.action.get.GetResponse) SingleFeatureLinearUniformInterpolator(org.opensearch.ad.dataprocessor.SingleFeatureLinearUniformInterpolator) IntegerSensitiveSingleFeatureLinearUniformInterpolator(org.opensearch.ad.dataprocessor.IntegerSensitiveSingleFeatureLinearUniformInterpolator) CheckpointWriteWorker(org.opensearch.ad.ratelimit.CheckpointWriteWorker) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ClusterService(org.opensearch.cluster.service.ClusterService) ActionListener(org.opensearch.action.ActionListener)

Example 14 with GetRequest

use of org.opensearch.action.get.GetRequest in project anomaly-detection by opensearch-project.

the class EntityColdStarterTests method testEmptyDataRange.

@SuppressWarnings("unchecked")
public void testEmptyDataRange() throws InterruptedException {
    Queue<double[]> samples = MLUtil.createQueueSamples(1);
    EntityModel model = new EntityModel(entity, samples, null);
    modelState = new ModelState<>(model, modelId, detectorId, ModelType.ENTITY.getName(), clock, priority);
    // the min-max range 894056973000L~894057860000L is too small and thus no data range can be found
    job = TestHelpers.randomAnomalyDetectorJob(true, Instant.ofEpochMilli(894057860000L), null);
    doAnswer(invocation -> {
        GetRequest request = invocation.getArgument(0);
        ActionListener<GetResponse> listener = invocation.getArgument(2);
        if (request.index().equals(AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX)) {
            listener.onResponse(TestHelpers.createGetResponse(job, detector.getDetectorId(), AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX));
        } else {
            listener.onResponse(TestHelpers.createGetResponse(detector, detector.getDetectorId(), AnomalyDetector.ANOMALY_DETECTORS_INDEX));
        }
        return null;
    }).when(clientUtil).asyncRequest(any(GetRequest.class), any(), any(ActionListener.class));
    doAnswer(invocation -> {
        ActionListener<Optional<Long>> listener = invocation.getArgument(2);
        listener.onResponse(Optional.of(894056973000L));
        return null;
    }).when(searchFeatureDao).getEntityMinDataTime(any(), any(), any());
    entityColdStarter.trainModel(entity, detectorId, modelState, listener);
    checkSemaphoreRelease();
    assertTrue(!model.getTrcf().isPresent());
    // the min-max range is too small and thus no data range can be found
    assertEquals("real sample size is " + model.getSamples().size(), 1, model.getSamples().size());
}
Also used : ActionListener(org.opensearch.action.ActionListener) Optional(java.util.Optional) GetRequest(org.opensearch.action.get.GetRequest) GetResponse(org.opensearch.action.get.GetResponse)

Example 15 with GetRequest

use of org.opensearch.action.get.GetRequest in project anomaly-detection by opensearch-project.

the class IndexAnomalyDetectorJobActionHandler method stopAnomalyDetectorJob.

/**
 * Stop anomaly detector job.
 * 1.If job not exists, return error message
 * 2.If job exists: a).if job state is disabled, return error message; b).if job state is enabled, disable job.
 *
 * @param detectorId detector identifier
 */
public void stopAnomalyDetectorJob(String detectorId) {
    GetRequest getRequest = new GetRequest(AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX).id(detectorId);
    client.get(getRequest, ActionListener.wrap(response -> {
        if (response.isExists()) {
            try (XContentParser parser = createXContentParserFromRegistry(xContentRegistry, response.getSourceAsBytesRef())) {
                ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
                AnomalyDetectorJob job = AnomalyDetectorJob.parse(parser);
                if (!job.isEnabled()) {
                    adTaskManager.stopLatestRealtimeTask(detectorId, ADTaskState.STOPPED, null, transportService, listener);
                } else {
                    AnomalyDetectorJob newJob = new AnomalyDetectorJob(job.getName(), job.getSchedule(), job.getWindowDelay(), false, job.getEnabledTime(), Instant.now(), Instant.now(), job.getLockDurationSeconds(), job.getUser(), job.getResultIndex());
                    indexAnomalyDetectorJob(newJob, () -> client.execute(StopDetectorAction.INSTANCE, new StopDetectorRequest(detectorId), stopAdDetectorListener(detectorId)));
                }
            } catch (IOException e) {
                String message = "Failed to parse anomaly detector job " + detectorId;
                logger.error(message, e);
                listener.onFailure(new OpenSearchStatusException(message, RestStatus.INTERNAL_SERVER_ERROR));
            }
        } else {
            listener.onFailure(new OpenSearchStatusException("Anomaly detector job not exist: " + detectorId, RestStatus.BAD_REQUEST));
        }
    }, exception -> listener.onFailure(exception)));
}
Also used : StopDetectorAction(org.opensearch.ad.transport.StopDetectorAction) Schedule(org.opensearch.jobscheduler.spi.schedule.Schedule) IndexResponse(org.opensearch.action.index.IndexResponse) OpenSearchStatusException(org.opensearch.OpenSearchStatusException) StopDetectorResponse(org.opensearch.ad.transport.StopDetectorResponse) ExceptionUtil.getShardsFailure(org.opensearch.ad.util.ExceptionUtil.getShardsFailure) ADTaskState(org.opensearch.ad.model.ADTaskState) StopDetectorRequest(org.opensearch.ad.transport.StopDetectorRequest) XContentParser(org.opensearch.common.xcontent.XContentParser) WriteRequest(org.opensearch.action.support.WriteRequest) Duration(java.time.Duration) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) XContentFactory(org.opensearch.common.xcontent.XContentFactory) ActionListener(org.opensearch.action.ActionListener) GetResponse(org.opensearch.action.get.GetResponse) Client(org.opensearch.client.Client) TimeValue(org.opensearch.common.unit.TimeValue) RestHandlerUtils.createXContentParserFromRegistry(org.opensearch.ad.util.RestHandlerUtils.createXContentParserFromRegistry) ANOMALY_DETECTORS_INDEX(org.opensearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX) GetRequest(org.opensearch.action.get.GetRequest) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) IOException(java.io.IOException) AnomalyDetectionIndices(org.opensearch.ad.indices.AnomalyDetectionIndices) ADTaskManager(org.opensearch.ad.task.ADTaskManager) Instant(java.time.Instant) RestStatus(org.opensearch.rest.RestStatus) TransportService(org.opensearch.transport.TransportService) AnomalyDetectorJobResponse(org.opensearch.ad.transport.AnomalyDetectorJobResponse) UPDATED(org.opensearch.action.DocWriteResponse.Result.UPDATED) Logger(org.apache.logging.log4j.Logger) CREATED(org.opensearch.action.DocWriteResponse.Result.CREATED) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) IntervalSchedule(org.opensearch.jobscheduler.spi.schedule.IntervalSchedule) IndexRequest(org.opensearch.action.index.IndexRequest) IntervalTimeConfiguration(org.opensearch.ad.model.IntervalTimeConfiguration) LogManager(org.apache.logging.log4j.LogManager) RestHandlerUtils(org.opensearch.ad.util.RestHandlerUtils) GetRequest(org.opensearch.action.get.GetRequest) StopDetectorRequest(org.opensearch.ad.transport.StopDetectorRequest) IOException(java.io.IOException) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) XContentParser(org.opensearch.common.xcontent.XContentParser) OpenSearchStatusException(org.opensearch.OpenSearchStatusException)

Aggregations

GetRequest (org.opensearch.action.get.GetRequest)81 GetResponse (org.opensearch.action.get.GetResponse)50 ActionListener (org.opensearch.action.ActionListener)48 IOException (java.io.IOException)34 Client (org.opensearch.client.Client)32 IndexRequest (org.opensearch.action.index.IndexRequest)25 XContentParser (org.opensearch.common.xcontent.XContentParser)24 SearchRequest (org.opensearch.action.search.SearchRequest)22 AnomalyDetector (org.opensearch.ad.model.AnomalyDetector)21 NamedXContentRegistry (org.opensearch.common.xcontent.NamedXContentRegistry)21 LogManager (org.apache.logging.log4j.LogManager)20 Logger (org.apache.logging.log4j.Logger)20 AnomalyDetectorJob (org.opensearch.ad.model.AnomalyDetectorJob)19 IndexNotFoundException (org.opensearch.index.IndexNotFoundException)19 List (java.util.List)18 XContentParserUtils.ensureExpectedToken (org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken)17 Optional (java.util.Optional)15 Set (java.util.Set)15 IntervalTimeConfiguration (org.opensearch.ad.model.IntervalTimeConfiguration)15 TransportService (org.opensearch.transport.TransportService)15