Search in sources :

Example 71 with IndexNotFoundException

use of org.opensearch.index.IndexNotFoundException in project anomaly-detection by opensearch-project.

the class CheckpointReadWorkerTests method testIndexNotFound.

public void testIndexNotFound() {
    doAnswer(invocation -> {
        MultiGetItemResponse[] items = new MultiGetItemResponse[1];
        items[0] = new MultiGetItemResponse(null, new MultiGetResponse.Failure(CommonName.CHECKPOINT_INDEX_NAME, "_doc", entity.getModelId(detectorId).get(), new IndexNotFoundException(CommonName.CHECKPOINT_INDEX_NAME)));
        ActionListener<MultiGetResponse> listener = invocation.getArgument(1);
        listener.onResponse(new MultiGetResponse(items));
        return null;
    }).when(checkpoint).batchRead(any(), any());
    worker.put(request);
    verify(coldstartQueue, times(1)).put(any());
    verify(entityCache, never()).hostIfPossible(any(), any());
}
Also used : MultiGetResponse(org.opensearch.action.get.MultiGetResponse) MultiGetItemResponse(org.opensearch.action.get.MultiGetItemResponse) IndexNotFoundException(org.opensearch.index.IndexNotFoundException)

Example 72 with IndexNotFoundException

use of org.opensearch.index.IndexNotFoundException in project anomaly-detection by opensearch-project.

the class CheckpointDao method deleteModelCheckpointByDetectorId.

/**
 * Delete checkpoints associated with a detector.  Used in multi-entity detector.
 * @param detectorID Detector Id
 */
public void deleteModelCheckpointByDetectorId(String detectorID) {
    // A bulk delete request is performed for each batch of matching documents. If a
    // search or bulk request is rejected, the requests are retried up to 10 times,
    // with exponential back off. If the maximum retry limit is reached, processing
    // halts and all failed requests are returned in the response. Any delete
    // requests that completed successfully still stick, they are not rolled back.
    DeleteByQueryRequest deleteRequest = new DeleteByQueryRequest(CommonName.CHECKPOINT_INDEX_NAME).setQuery(new MatchQueryBuilder(DETECTOR_ID, detectorID)).setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN).setAbortOnVersionConflict(// when current delete happens, previous might not finish.
    false).setRequestsPerSecond(// throttle delete requests
    500);
    logger.info("Delete checkpoints of detector {}", detectorID);
    client.execute(DeleteByQueryAction.INSTANCE, deleteRequest, ActionListener.wrap(response -> {
        if (response.isTimedOut() || !response.getBulkFailures().isEmpty() || !response.getSearchFailures().isEmpty()) {
            logFailure(response, detectorID);
        }
        // can return 0 docs get deleted because:
        // 1) we cannot find matching docs
        // 2) bad stats from OpenSearch. In this case, docs are deleted, but
        // OpenSearch says deleted is 0.
        logger.info("{} " + DOC_GOT_DELETED_LOG_MSG, response.getDeleted());
    }, exception -> {
        if (exception instanceof IndexNotFoundException) {
            logger.info(INDEX_DELETED_LOG_MSG + " {}", detectorID);
        } else {
            // Gonna eventually delete in daily cron.
            logger.error(NOT_ABLE_TO_DELETE_LOG_MSG, exception);
        }
    }));
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) MultiGetResponse(org.opensearch.action.get.MultiGetResponse) ResourceNotFoundException(org.opensearch.ad.common.exception.ResourceNotFoundException) IndexResponse(org.opensearch.action.index.IndexResponse) ThresholdedRandomCutForestMapper(com.amazon.randomcutforest.parkservices.state.ThresholdedRandomCutForestMapper) ZonedDateTime(java.time.ZonedDateTime) BulkRequest(org.opensearch.action.bulk.BulkRequest) BulkAction(org.opensearch.action.bulk.BulkAction) AnomalyDetectionException(org.opensearch.ad.common.exception.AnomalyDetectionException) ADIndex(org.opensearch.ad.indices.ADIndex) Locale(java.util.Locale) BulkItemResponse(org.opensearch.action.bulk.BulkItemResponse) V1JsonToV2StateConverter(com.amazon.randomcutforest.serialize.json.v1.V1JsonToV2StateConverter) Gson(com.google.gson.Gson) Map(java.util.Map) ZoneOffset(java.time.ZoneOffset) ActionListener(org.opensearch.action.ActionListener) RandomCutForestMapper(com.amazon.randomcutforest.state.RandomCutForestMapper) GetResponse(org.opensearch.action.get.GetResponse) DeleteRequest(org.opensearch.action.delete.DeleteRequest) MultiGetAction(org.opensearch.action.get.MultiGetAction) Client(org.opensearch.client.Client) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool) ExceptionsHelper(org.opensearch.ExceptionsHelper) PrivilegedAction(java.security.PrivilegedAction) Instant(java.time.Instant) ScrollableHitSource(org.opensearch.index.reindex.ScrollableHitSource) RandomCutForest(com.amazon.randomcutforest.RandomCutForest) Base64(java.util.Base64) List(java.util.List) ThresholdedRandomCutForestState(com.amazon.randomcutforest.parkservices.state.ThresholdedRandomCutForestState) Logger(org.apache.logging.log4j.Logger) ProtostuffIOUtil(io.protostuff.ProtostuffIOUtil) Entry(java.util.Map.Entry) Optional(java.util.Optional) ResourceAlreadyExistsException(org.opensearch.ResourceAlreadyExistsException) UpdateRequest(org.opensearch.action.update.UpdateRequest) AccessController(java.security.AccessController) RandomCutForestState(com.amazon.randomcutforest.state.RandomCutForestState) Precision(com.amazon.randomcutforest.config.Precision) UpdateResponse(org.opensearch.action.update.UpdateResponse) HashMap(java.util.HashMap) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) IndicesOptions(org.opensearch.action.support.IndicesOptions) JsonParser(com.google.gson.JsonParser) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) ArrayList(java.util.ArrayList) Schema(io.protostuff.Schema) DeleteResponse(org.opensearch.action.delete.DeleteResponse) CommonName(org.opensearch.ad.constant.CommonName) ClientUtil(org.opensearch.ad.util.ClientUtil) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) GetRequest(org.opensearch.action.get.GetRequest) IOException(java.io.IOException) AnomalyDetectionIndices(org.opensearch.ad.indices.AnomalyDetectionIndices) LinkedBuffer(io.protostuff.LinkedBuffer) BulkByScrollResponse(org.opensearch.index.reindex.BulkByScrollResponse) Entity(org.opensearch.ad.model.Entity) BulkResponse(org.opensearch.action.bulk.BulkResponse) ThresholdedRandomCutForest(com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest) MatchQueryBuilder(org.opensearch.index.query.MatchQueryBuilder) DeleteByQueryRequest(org.opensearch.index.reindex.DeleteByQueryRequest) DeleteByQueryAction(org.opensearch.index.reindex.DeleteByQueryAction) ArrayDeque(java.util.ArrayDeque) IndexRequest(org.opensearch.action.index.IndexRequest) LogManager(org.apache.logging.log4j.LogManager) MultiGetRequest(org.opensearch.action.get.MultiGetRequest) DeleteByQueryRequest(org.opensearch.index.reindex.DeleteByQueryRequest) MatchQueryBuilder(org.opensearch.index.query.MatchQueryBuilder) IndexNotFoundException(org.opensearch.index.IndexNotFoundException)

Example 73 with IndexNotFoundException

use of org.opensearch.index.IndexNotFoundException in project anomaly-detection by opensearch-project.

the class DailyCron method run.

@Override
public void run() {
    DeleteByQueryRequest deleteRequest = new DeleteByQueryRequest(CommonName.CHECKPOINT_INDEX_NAME).setQuery(QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(CheckpointDao.TIMESTAMP).lte(clock.millis() - checkpointTtl.toMillis()).format(CommonName.EPOCH_MILLIS_FORMAT))).setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN);
    clientUtil.execute(DeleteByQueryAction.INSTANCE, deleteRequest, ActionListener.wrap(response -> {
        // if 0 docs get deleted, it means our query cannot find any matching doc
        LOG.info("{} " + CHECKPOINT_DELETED_MSG, response.getDeleted());
    }, exception -> {
        if (exception instanceof IndexNotFoundException) {
            LOG.info(CHECKPOINT_NOT_EXIST_MSG);
        } else {
            // Gonna eventually delete in maintenance window.
            LOG.error(CANNOT_DELETE_OLD_CHECKPOINT_MSG, exception);
        }
    }));
}
Also used : QueryBuilders(org.opensearch.index.query.QueryBuilders) CommonName(org.opensearch.ad.constant.CommonName) ClientUtil(org.opensearch.ad.util.ClientUtil) CheckpointDao(org.opensearch.ad.ml.CheckpointDao) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) IndicesOptions(org.opensearch.action.support.IndicesOptions) Logger(org.apache.logging.log4j.Logger) Duration(java.time.Duration) Clock(java.time.Clock) DeleteByQueryRequest(org.opensearch.index.reindex.DeleteByQueryRequest) ActionListener(org.opensearch.action.ActionListener) DeleteByQueryAction(org.opensearch.index.reindex.DeleteByQueryAction) LogManager(org.apache.logging.log4j.LogManager) DeleteByQueryRequest(org.opensearch.index.reindex.DeleteByQueryRequest) IndexNotFoundException(org.opensearch.index.IndexNotFoundException)

Example 74 with IndexNotFoundException

use of org.opensearch.index.IndexNotFoundException in project anomaly-detection by opensearch-project.

the class EntityProfileRunner method getJob.

private void getJob(String detectorId, Entity entityValue, Set<EntityProfileName> profilesToCollect, AnomalyDetector detector, EntityProfileResponse entityProfileResponse, ActionListener<EntityProfile> listener) {
    GetRequest getRequest = new GetRequest(ANOMALY_DETECTOR_JOB_INDEX, detectorId);
    client.get(getRequest, ActionListener.wrap(getResponse -> {
        if (getResponse != null && getResponse.isExists()) {
            try (XContentParser parser = XContentType.JSON.xContent().createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, getResponse.getSourceAsString())) {
                ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
                AnomalyDetectorJob job = AnomalyDetectorJob.parse(parser);
                int totalResponsesToWait = 0;
                if (profilesToCollect.contains(EntityProfileName.INIT_PROGRESS) || profilesToCollect.contains(EntityProfileName.STATE)) {
                    totalResponsesToWait++;
                }
                if (profilesToCollect.contains(EntityProfileName.ENTITY_INFO)) {
                    totalResponsesToWait++;
                }
                if (profilesToCollect.contains(EntityProfileName.MODELS)) {
                    totalResponsesToWait++;
                }
                MultiResponsesDelegateActionListener<EntityProfile> delegateListener = new MultiResponsesDelegateActionListener<EntityProfile>(listener, totalResponsesToWait, CommonErrorMessages.FAIL_FETCH_ERR_MSG + entityValue + " of detector " + detectorId, false);
                if (profilesToCollect.contains(EntityProfileName.MODELS)) {
                    EntityProfile.Builder builder = new EntityProfile.Builder();
                    if (false == job.isEnabled()) {
                        delegateListener.onResponse(builder.build());
                    } else {
                        delegateListener.onResponse(builder.modelProfile(entityProfileResponse.getModelProfile()).build());
                    }
                }
                if (profilesToCollect.contains(EntityProfileName.INIT_PROGRESS) || profilesToCollect.contains(EntityProfileName.STATE)) {
                    profileStateRelated(entityProfileResponse.getTotalUpdates(), detectorId, entityValue, profilesToCollect, detector, job, delegateListener);
                }
                if (profilesToCollect.contains(EntityProfileName.ENTITY_INFO)) {
                    long enabledTimeMs = job.getEnabledTime().toEpochMilli();
                    SearchRequest lastSampleTimeRequest = createLastSampleTimeRequest(detectorId, enabledTimeMs, entityValue, detector.getResultIndex());
                    EntityProfile.Builder builder = new EntityProfile.Builder();
                    Optional<Boolean> isActiveOp = entityProfileResponse.isActive();
                    if (isActiveOp.isPresent()) {
                        builder.isActive(isActiveOp.get());
                    }
                    builder.lastActiveTimestampMs(entityProfileResponse.getLastActiveMs());
                    client.search(lastSampleTimeRequest, ActionListener.wrap(searchResponse -> {
                        Optional<Long> latestSampleTimeMs = ParseUtils.getLatestDataTime(searchResponse);
                        if (latestSampleTimeMs.isPresent()) {
                            builder.lastSampleTimestampMs(latestSampleTimeMs.get());
                        }
                        delegateListener.onResponse(builder.build());
                    }, 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());
                    }));
                }
            } catch (Exception e) {
                logger.error(CommonErrorMessages.FAIL_TO_GET_PROFILE_MSG, e);
                listener.onFailure(e);
            }
        } else {
            sendUnknownState(profilesToCollect, entityValue, true, listener);
        }
    }, exception -> {
        if (exception instanceof IndexNotFoundException) {
            logger.info(exception.getMessage());
            sendUnknownState(profilesToCollect, entityValue, true, listener);
        } else {
            logger.error(CommonErrorMessages.FAIL_TO_GET_PROFILE_MSG + detectorId, exception);
            listener.onFailure(exception);
        }
    }));
}
Also used : EntityProfileRequest(org.opensearch.ad.transport.EntityProfileRequest) EntityProfileName(org.opensearch.ad.model.EntityProfileName) XContentParser(org.opensearch.common.xcontent.XContentParser) ANOMALY_DETECTOR_JOB_INDEX(org.opensearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX) EntityProfileResponse(org.opensearch.ad.transport.EntityProfileResponse) Map(java.util.Map) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) SearchRequest(org.opensearch.action.search.SearchRequest) ActionListener(org.opensearch.action.ActionListener) EntityProfile(org.opensearch.ad.model.EntityProfile) NestedQueryBuilder(org.opensearch.index.query.NestedQueryBuilder) QueryBuilders(org.opensearch.index.query.QueryBuilders) Client(org.opensearch.client.Client) CommonName(org.opensearch.ad.constant.CommonName) NumericSetting(org.opensearch.ad.settings.NumericSetting) Preference(org.opensearch.cluster.routing.Preference) InitProgressProfile(org.opensearch.ad.model.InitProgressProfile) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) ANOMALY_DETECTORS_INDEX(org.opensearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX) GetRequest(org.opensearch.action.get.GetRequest) LoggingDeprecationHandler(org.opensearch.common.xcontent.LoggingDeprecationHandler) Set(java.util.Set) TermQueryBuilder(org.opensearch.index.query.TermQueryBuilder) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) ScoreMode(org.apache.lucene.search.join.ScoreMode) MultiResponsesDelegateActionListener(org.opensearch.ad.util.MultiResponsesDelegateActionListener) AggregationBuilders(org.opensearch.search.aggregations.AggregationBuilders) List(java.util.List) CommonErrorMessages(org.opensearch.ad.constant.CommonErrorMessages) Logger(org.apache.logging.log4j.Logger) AnomalyResult(org.opensearch.ad.model.AnomalyResult) Entity(org.opensearch.ad.model.Entity) EntityState(org.opensearch.ad.model.EntityState) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) Optional(java.util.Optional) XContentType(org.opensearch.common.xcontent.XContentType) IntervalTimeConfiguration(org.opensearch.ad.model.IntervalTimeConfiguration) LogManager(org.apache.logging.log4j.LogManager) EntityProfileAction(org.opensearch.ad.transport.EntityProfileAction) ParseUtils(org.opensearch.ad.util.ParseUtils) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) SearchRequest(org.opensearch.action.search.SearchRequest) Optional(java.util.Optional) NestedQueryBuilder(org.opensearch.index.query.NestedQueryBuilder) TermQueryBuilder(org.opensearch.index.query.TermQueryBuilder) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) MultiResponsesDelegateActionListener(org.opensearch.ad.util.MultiResponsesDelegateActionListener) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) GetRequest(org.opensearch.action.get.GetRequest) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) EntityProfile(org.opensearch.ad.model.EntityProfile) XContentParser(org.opensearch.common.xcontent.XContentParser)

Example 75 with IndexNotFoundException

use of org.opensearch.index.IndexNotFoundException in project anomaly-detection by opensearch-project.

the class ADTaskManagerTests method testDeleteADTasksWithException.

@SuppressWarnings("unchecked")
public void testDeleteADTasksWithException() {
    doAnswer(invocation -> {
        ActionListener<BulkByScrollResponse> actionListener = invocation.getArgument(2);
        actionListener.onFailure(new IndexNotFoundException(DETECTION_STATE_INDEX));
        return null;
    }).doAnswer(invocation -> {
        ActionListener<BulkByScrollResponse> actionListener = invocation.getArgument(2);
        actionListener.onFailure(new RuntimeException("test"));
        return null;
    }).when(client).execute(any(), any(), any());
    String detectorId = randomAlphaOfLength(5);
    AnomalyDetectorFunction function = mock(AnomalyDetectorFunction.class);
    ActionListener<DeleteResponse> listener = mock(ActionListener.class);
    adTaskManager.deleteADTasks(detectorId, function, listener);
    verify(function, times(1)).execute();
    verify(listener, never()).onFailure(any());
    adTaskManager.deleteADTasks(detectorId, function, listener);
    verify(function, times(1)).execute();
    verify(listener, times(1)).onFailure(any());
}
Also used : ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) IndexResponse(org.opensearch.action.index.IndexResponse) HashRing(org.opensearch.ad.cluster.HashRing) Version(org.opensearch.Version) ADTaskState(org.opensearch.ad.model.ADTaskState) AnomalyDetectorFunction(org.opensearch.ad.rest.handler.AnomalyDetectorFunction) Mockito.doThrow(org.mockito.Mockito.doThrow) ADUnitTestCase(org.opensearch.ad.ADUnitTestCase) Mockito.doAnswer(org.mockito.Mockito.doAnswer) TestHelpers.randomIntervalSchedule(org.opensearch.ad.TestHelpers.randomIntervalSchedule) MAX_OLD_AD_TASK_DOCS_PER_DETECTOR(org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_OLD_AD_TASK_DOCS_PER_DETECTOR) Map(java.util.Map) InternalAggregations(org.opensearch.search.aggregations.InternalAggregations) ActionListener(org.opensearch.action.ActionListener) Mockito.doReturn(org.mockito.Mockito.doReturn) ADStatsNodeResponse(org.opensearch.ad.transport.ADStatsNodeResponse) MAX_RUNNING_ENTITIES_PER_DETECTOR_FOR_HISTORICAL_ANALYSIS(org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_RUNNING_ENTITIES_PER_DETECTOR_FOR_HISTORICAL_ANALYSIS) Client(org.opensearch.client.Client) TimeValue(org.opensearch.common.unit.TimeValue) Index(org.opensearch.index.Index) SearchHit(org.opensearch.search.SearchHit) GetResult(org.opensearch.index.get.GetResult) Settings(org.opensearch.common.settings.Settings) DETECTION_STATE_INDEX(org.opensearch.ad.constant.CommonName.DETECTION_STATE_INDEX) TransportService(org.opensearch.transport.TransportService) RandomCutForest(com.amazon.randomcutforest.RandomCutForest) ArgumentMatchers.anyFloat(org.mockito.ArgumentMatchers.anyFloat) TestHelpers(org.opensearch.ad.TestHelpers) DocWriteResponse(org.opensearch.action.DocWriteResponse) Mockito.mock(org.mockito.Mockito.mock) BATCH_TASK_PIECE_INTERVAL_SECONDS(org.opensearch.ad.settings.AnomalyDetectorSettings.BATCH_TASK_PIECE_INTERVAL_SECONDS) MAX_BATCH_TASK_PER_NODE(org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_BATCH_TASK_PER_NODE) TestHelpers.randomFeature(org.opensearch.ad.TestHelpers.randomFeature) UpdateResponse(org.opensearch.action.update.UpdateResponse) ThreadPool(org.opensearch.threadpool.ThreadPool) ADTaskProfileResponse(org.opensearch.ad.transport.ADTaskProfileResponse) DocWriteRequest(org.opensearch.action.DocWriteRequest) ArgumentMatchers.anyMap(org.mockito.ArgumentMatchers.anyMap) TestHelpers.randomDetectionDateRange(org.opensearch.ad.TestHelpers.randomDetectionDateRange) SearchHits(org.opensearch.search.SearchHits) Mockito.spy(org.mockito.Mockito.spy) ADTaskProfile(org.opensearch.ad.model.ADTaskProfile) TestHelpers.randomAdTask(org.opensearch.ad.TestHelpers.randomAdTask) ArrayList(java.util.ArrayList) UNASSIGNED_SEQ_NO(org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) DeleteResponse(org.opensearch.action.delete.DeleteResponse) SearchRequest(org.opensearch.action.search.SearchRequest) CommonName(org.opensearch.ad.constant.CommonName) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) InternalSearchResponse(org.opensearch.search.internal.InternalSearchResponse) TotalHits(org.apache.lucene.search.TotalHits) Mockito.never(org.mockito.Mockito.never) ChronoUnit(java.time.temporal.ChronoUnit) ShardSearchFailure(org.opensearch.action.search.ShardSearchFailure) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) ClusterService(org.opensearch.cluster.service.ClusterService) ADTaskAction(org.opensearch.ad.model.ADTaskAction) DeleteByQueryAction(org.opensearch.index.reindex.DeleteByQueryAction) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DELETE_AD_RESULT_WHEN_DELETE_DETECTOR(org.opensearch.ad.settings.AnomalyDetectorSettings.DELETE_AD_RESULT_WHEN_DELETE_DETECTOR) ToXContent(org.opensearch.common.xcontent.ToXContent) ThreadContext(org.opensearch.common.util.concurrent.ThreadContext) TestHelpers.randomAnomalyDetector(org.opensearch.ad.TestHelpers.randomAnomalyDetector) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) MapperService(org.opensearch.index.mapper.MapperService) IndexAnomalyDetectorJobActionHandler(org.opensearch.ad.rest.handler.IndexAnomalyDetectorJobActionHandler) Locale(java.util.Locale) BulkItemResponse(org.opensearch.action.bulk.BulkItemResponse) TestHelpers.randomDetector(org.opensearch.ad.TestHelpers.randomDetector) GetResponse(org.opensearch.action.get.GetResponse) InternalStatNames(org.opensearch.ad.stats.InternalStatNames) TestHelpers.randomIntervalTimeConfiguration(org.opensearch.ad.TestHelpers.randomIntervalTimeConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap) ADTaskType(org.opensearch.ad.model.ADTaskType) ADTaskProfileNodeResponse(org.opensearch.ad.transport.ADTaskProfileNodeResponse) Instant(java.time.Instant) TransportAddress(org.opensearch.common.transport.TransportAddress) AnomalyDetectorJobResponse(org.opensearch.ad.transport.AnomalyDetectorJobResponse) List(java.util.List) ForwardADTaskRequest(org.opensearch.ad.transport.ForwardADTaskRequest) DuplicateTaskException(org.opensearch.ad.common.exception.DuplicateTaskException) DetectionDateRange(org.opensearch.ad.model.DetectionDateRange) Optional(java.util.Optional) ResourceAlreadyExistsException(org.opensearch.ResourceAlreadyExistsException) ANOMALY_RESULT_INDEX_ALIAS(org.opensearch.ad.constant.CommonName.ANOMALY_RESULT_INDEX_ALIAS) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) REQUEST_TIMEOUT(org.opensearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT) ADStatsNodesResponse(org.opensearch.ad.transport.ADStatsNodesResponse) DiscoveryNodeFilterer(org.opensearch.ad.util.DiscoveryNodeFilterer) BytesReference(org.opensearch.common.bytes.BytesReference) ADTask(org.opensearch.ad.model.ADTask) TestHelpers.randomUser(org.opensearch.ad.TestHelpers.randomUser) Deque(java.util.Deque) Captor(org.mockito.Captor) ArgumentCaptor(org.mockito.ArgumentCaptor) ImmutableList(com.google.common.collect.ImmutableList) SearchResponse(org.opensearch.action.search.SearchResponse) ClusterSettings(org.opensearch.common.settings.ClusterSettings) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) ExecutorService(java.util.concurrent.ExecutorService) Collections.emptyMap(java.util.Collections.emptyMap) Collections.emptySet(java.util.Collections.emptySet) VersionConflictEngineException(org.opensearch.index.engine.VersionConflictEngineException) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) Entity.createSingleAttributeEntity(org.opensearch.ad.model.Entity.createSingleAttributeEntity) MockSimpleLog(org.opensearch.ad.mock.model.MockSimpleLog) TransportResponseHandler(org.opensearch.transport.TransportResponseHandler) AnomalyDetectionIndices(org.opensearch.ad.indices.AnomalyDetectionIndices) Mockito.when(org.mockito.Mockito.when) CreateIndexResponse(org.opensearch.action.admin.indices.create.CreateIndexResponse) Mockito.verify(org.mockito.Mockito.verify) CREATE_INDEX_NOT_ACKNOWLEDGED(org.opensearch.ad.constant.CommonErrorMessages.CREATE_INDEX_NOT_ACKNOWLEDGED) Consumer(java.util.function.Consumer) ShardId(org.opensearch.index.shard.ShardId) BulkByScrollResponse(org.opensearch.index.reindex.BulkByScrollResponse) Entity(org.opensearch.ad.model.Entity) BulkResponse(org.opensearch.action.bulk.BulkResponse) User(org.opensearch.commons.authuser.User) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) ThresholdedRandomCutForest(com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest) ClusterName(org.opensearch.cluster.ClusterName) Collections(java.util.Collections) DeleteResponse(org.opensearch.action.delete.DeleteResponse) ActionListener(org.opensearch.action.ActionListener) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) AnomalyDetectorFunction(org.opensearch.ad.rest.handler.AnomalyDetectorFunction) BulkByScrollResponse(org.opensearch.index.reindex.BulkByScrollResponse)

Aggregations

IndexNotFoundException (org.opensearch.index.IndexNotFoundException)107 ActionListener (org.opensearch.action.ActionListener)32 ClusterState (org.opensearch.cluster.ClusterState)26 IOException (java.io.IOException)25 ThreadContext (org.opensearch.common.util.concurrent.ThreadContext)25 Map (java.util.Map)23 Client (org.opensearch.client.Client)23 ArrayList (java.util.ArrayList)21 Settings (org.opensearch.common.settings.Settings)21 Logger (org.apache.logging.log4j.Logger)20 List (java.util.List)19 LogManager (org.apache.logging.log4j.LogManager)19 SearchResponse (org.opensearch.action.search.SearchResponse)19 HashMap (java.util.HashMap)18 GetRequest (org.opensearch.action.get.GetRequest)18 AnomalyDetector (org.opensearch.ad.model.AnomalyDetector)18 NamedXContentRegistry (org.opensearch.common.xcontent.NamedXContentRegistry)18 ClusterService (org.opensearch.cluster.service.ClusterService)17 XContentParser (org.opensearch.common.xcontent.XContentParser)17 DeleteResponse (org.opensearch.action.delete.DeleteResponse)16