diff --git a/build.gradle b/build.gradle index 35c45f6c..5345326a 100644 --- a/build.gradle +++ b/build.gradle @@ -356,6 +356,10 @@ afterEvaluate { spotless { java { + removeUnusedImports() + importOrder 'java', 'javax', 'org', 'com' + licenseHeaderFile 'spotless.license.java' + eclipse().configFile rootProject.file('.eclipseformat.xml') } } diff --git a/spotless.license.java b/spotless.license.java new file mode 100644 index 00000000..2e72cee8 --- /dev/null +++ b/spotless.license.java @@ -0,0 +1,16 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + + diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunner.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunner.java index 06814e93..05099c48 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunner.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunner.java @@ -15,6 +15,35 @@ package com.amazon.opendistroforelasticsearch.ad; +import static com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin.AD_THREAD_POOL_NAME; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE; +import static org.elasticsearch.action.DocWriteResponse.Result.CREATED; +import static org.elasticsearch.action.DocWriteResponse.Result.UPDATED; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.get.GetRequest; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.index.IndexRequest; +import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.action.support.WriteRequest; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; +import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.threadpool.ThreadPool; + import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; import com.amazon.opendistroforelasticsearch.ad.common.exception.EndRunException; import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; @@ -36,34 +65,6 @@ import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.IntervalSchedule; import com.amazon.opendistroforelasticsearch.jobscheduler.spi.utils.LockService; import com.google.common.base.Throwables; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.get.GetRequest; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.client.Client; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; -import org.elasticsearch.common.xcontent.NamedXContentRegistry; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.threadpool.ThreadPool; - -import java.io.IOException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; - -import static com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin.AD_THREAD_POOL_NAME; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE; -import static org.elasticsearch.action.DocWriteResponse.Result.CREATED; -import static org.elasticsearch.action.DocWriteResponse.Result.UPDATED; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; /** * JobScheduler will call AD job runner to get anomaly result periodically diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorPlugin.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorPlugin.java index 4ace6218..f01c563a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorPlugin.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorPlugin.java @@ -17,6 +17,55 @@ import static java.util.Collections.unmodifiableList; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.time.Clock; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.elasticsearch.SpecialPermission; +import org.elasticsearch.action.ActionRequest; +import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.NamedDiff; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; +import org.elasticsearch.cluster.metadata.MetaData.Custom; +import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.settings.ClusterSettings; +import org.elasticsearch.common.settings.IndexScopedSettings; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.settings.SettingsFilter; +import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.XContentParserUtils; +import org.elasticsearch.env.Environment; +import org.elasticsearch.env.NodeEnvironment; +import org.elasticsearch.indices.SystemIndexDescriptor; +import org.elasticsearch.monitor.jvm.JvmService; +import org.elasticsearch.plugins.ActionPlugin; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.plugins.ScriptPlugin; +import org.elasticsearch.plugins.SystemIndexPlugin; +import org.elasticsearch.rest.RestController; +import org.elasticsearch.rest.RestHandler; +import org.elasticsearch.script.ScriptService; +import org.elasticsearch.threadpool.ExecutorBuilder; +import org.elasticsearch.threadpool.FixedExecutorBuilder; +import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.watcher.ResourceWatcherService; + import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; import com.amazon.opendistroforelasticsearch.ad.cluster.ADClusterEventListener; import com.amazon.opendistroforelasticsearch.ad.cluster.ADMetaData; @@ -87,54 +136,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; -import org.elasticsearch.SpecialPermission; -import org.elasticsearch.action.ActionRequest; -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.cluster.NamedDiff; -import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; -import org.elasticsearch.cluster.metadata.MetaData.Custom; -import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.IndexScopedSettings; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsFilter; -import org.elasticsearch.common.util.concurrent.EsExecutors; -import org.elasticsearch.common.xcontent.NamedXContentRegistry; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.XContentParserUtils; -import org.elasticsearch.env.Environment; -import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.monitor.jvm.JvmService; -import org.elasticsearch.indices.SystemIndexDescriptor; -import org.elasticsearch.plugins.ActionPlugin; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.plugins.ScriptPlugin; -import org.elasticsearch.plugins.SystemIndexPlugin; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestHandler; -import org.elasticsearch.script.ScriptService; -import org.elasticsearch.threadpool.ExecutorBuilder; -import org.elasticsearch.threadpool.FixedExecutorBuilder; -import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.watcher.ResourceWatcherService; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.time.Clock; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.TimeZone; -import java.util.function.Supplier; -import java.util.stream.Collectors; -import java.util.stream.Stream; /** * Entry point of AD plugin. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRunner.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRunner.java index 5a613b50..26909482 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRunner.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,18 @@ package com.amazon.opendistroforelasticsearch.ad; +import java.io.IOException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.action.ActionListener; + import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; import com.amazon.opendistroforelasticsearch.ad.feature.Features; import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; @@ -23,17 +35,6 @@ import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; import com.amazon.opendistroforelasticsearch.ad.model.Feature; import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.elasticsearch.action.ActionListener; - -import java.io.IOException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; /** * Runner to trigger an anomaly detector. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/annotation/Generated.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/annotation/Generated.java index 74e061ce..cf277c49 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/annotation/Generated.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/annotation/Generated.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerService.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerService.java index ef6aea1b..a12ebe10 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerService.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerService.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.breaker; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.monitor.jvm.JvmService; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - /** * Class {@code ADCircuitBreakerService} provide storing, retrieving circuit breakers functions. * diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/BreakerName.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/BreakerName.java index 5269c643..87f7a8e7 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/BreakerName.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/BreakerName.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/CircuitBreaker.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/CircuitBreaker.java index 67223e8a..f5f2819b 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/CircuitBreaker.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/CircuitBreaker.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreaker.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreaker.java index 1d5235db..d4e13613 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreaker.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreaker.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ThresholdCircuitBreaker.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ThresholdCircuitBreaker.java index 4b381267..fb14ef50 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ThresholdCircuitBreaker.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/breaker/ThresholdCircuitBreaker.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListener.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListener.java index 4ff2d5b7..18f06384 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListener.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListener.java @@ -19,9 +19,6 @@ import java.util.Set; import java.util.concurrent.Semaphore; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.cluster.ClusterChangedEvent; @@ -32,6 +29,9 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.gateway.GatewayService; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; + public class ADClusterEventListener implements ClusterStateListener { private static final Logger LOG = LogManager.getLogger(ADClusterEventListener.class); static final String NODE_NOT_APPLIED_MSG = "AD does not use master or ultrawarm nodes"; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaData.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaData.java index b59b6efd..8f2b6986 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaData.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaData.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/AnomalyDetectorGraveyard.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/AnomalyDetectorGraveyard.java index 06e5d1c4..bbf1cca9 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/AnomalyDetectorGraveyard.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/AnomalyDetectorGraveyard.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCron.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCron.java index 1a10d8d8..0fb2f2d0 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCron.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCron.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -18,10 +18,6 @@ import java.time.Clock; import java.time.Duration; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.ml.CheckpointDao; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -32,6 +28,10 @@ import org.elasticsearch.index.reindex.DeleteByQueryAction; import org.elasticsearch.index.reindex.DeleteByQueryRequest; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.ml.CheckpointDao; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; + public class DailyCron implements Runnable { private static final Logger LOG = LogManager.getLogger(DailyCron.class); protected static final String FIELD_MODEL = "queue"; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetector.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetector.java index cf67902b..ec8c51d6 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetector.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetector.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -21,9 +21,6 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -43,6 +40,10 @@ import org.elasticsearch.index.reindex.DeleteByQueryRequest; import org.elasticsearch.index.reindex.ScrollableHitSource; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; + public class DeleteDetector { private static final Logger LOG = LogManager.getLogger(DeleteDetector.class); private static final String UPDATE_TASK_NAME = "update-detector-graveyard"; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListener.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListener.java index c8e6bedb..f3192aa7 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListener.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListener.java @@ -23,13 +23,12 @@ import org.elasticsearch.common.component.LifecycleListener; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.threadpool.Scheduler.Cancellable; +import org.elasticsearch.threadpool.ThreadPool; import com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings; import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; -import org.elasticsearch.threadpool.ThreadPool; - public class MasterEventListener implements LocalNodeMasterListener { private Cancellable dailyCron; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/AnomalyDetectionException.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/AnomalyDetectionException.java index 92a8c513..19c6014a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/AnomalyDetectionException.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/AnomalyDetectionException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ClientException.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ClientException.java index 5b5f1d50..4faa2d66 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ClientException.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ClientException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/EndRunException.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/EndRunException.java index a394634f..118a6869 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/EndRunException.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/EndRunException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/InternalFailure.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/InternalFailure.java index 1be08c15..eeef050c 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/InternalFailure.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/InternalFailure.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededException.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededException.java index e801c9f5..794e9ba7 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededException.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ResourceNotFoundException.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ResourceNotFoundException.java index ab9f532e..e69f81fd 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ResourceNotFoundException.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/common/exception/ResourceNotFoundException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java index edc40a00..bd5ef67a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonMessageAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java index bed9f174..8f730ccb 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/constant/CommonName.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolator.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolator.java index 8bd1622c..2ceb2483 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolator.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolator.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/Interpolator.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/Interpolator.java index 57be5eaa..8a0ee13c 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/Interpolator.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/Interpolator.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolator.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolator.java index d28992e8..90d5b240 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolator.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolator.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolator.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolator.java index e52ef9da..289185dc 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolator.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolator.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManager.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManager.java index 07e160bc..8f0d833d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManager.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.feature; +import static java.util.Arrays.copyOfRange; +import static org.apache.commons.math3.linear.MatrixUtils.createRealMatrix; + import java.io.IOException; import java.time.Clock; import java.time.Duration; @@ -34,17 +37,13 @@ import java.util.stream.IntStream; import java.util.stream.Stream; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; import com.amazon.opendistroforelasticsearch.ad.dataprocessor.Interpolator; - -import static java.util.Arrays.copyOfRange; - -import static org.apache.commons.math3.linear.MatrixUtils.createRealMatrix; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; /** * A facade managing feature data operations and buffers. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/Features.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/Features.java index 01b4e092..8a2828e3 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/Features.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/Features.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDao.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDao.java index 2323b897..44d48443 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDao.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,11 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.feature; +import static org.apache.commons.math3.linear.MatrixUtils.createRealMatrix; + import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayDeque; +import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -29,10 +31,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; -import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -41,20 +39,22 @@ import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; +import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.bucket.range.InternalDateRange; +import org.elasticsearch.search.aggregations.metrics.InternalTDigestPercentiles; import org.elasticsearch.search.aggregations.metrics.Max; -import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.elasticsearch.common.xcontent.NamedXContentRegistry; -import org.elasticsearch.search.aggregations.Aggregation; import org.elasticsearch.search.aggregations.metrics.NumericMetricsAggregation.SingleValue; -import org.elasticsearch.search.aggregations.metrics.InternalTDigestPercentiles; import org.elasticsearch.search.aggregations.metrics.Percentile; +import org.elasticsearch.search.builder.SearchSourceBuilder; import com.amazon.opendistroforelasticsearch.ad.dataprocessor.Interpolator; - -import static org.apache.commons.math3.linear.MatrixUtils.createRealMatrix; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; +import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; /** * DAO for features from search. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SinglePointFeatures.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SinglePointFeatures.java index 1b548eb7..f0ab7efb 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SinglePointFeatures.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/feature/SinglePointFeatures.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndices.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndices.java index 049eb9ca..9c125f3d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndices.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndices.java @@ -15,11 +15,17 @@ package com.amazon.opendistroforelasticsearch.ad.indices; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; -import com.google.common.base.Charsets; -import com.google.common.io.Resources; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_INDEX_MAX_AGE; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_MAX_DOCS; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_ROLLOVER_PERIOD; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.ANOMALY_DETECTORS_INDEX_MAPPING_FILE; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.ANOMALY_DETECTOR_JOBS_INDEX_MAPPING_FILE; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.ANOMALY_RESULTS_INDEX_MAPPING_FILE; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; + +import java.io.IOException; +import java.net.URL; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -38,16 +44,11 @@ import org.elasticsearch.threadpool.Scheduler; import org.elasticsearch.threadpool.ThreadPool; -import java.io.IOException; -import java.net.URL; - -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_INDEX_MAX_AGE; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_MAX_DOCS; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.AD_RESULT_HISTORY_ROLLOVER_PERIOD; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.ANOMALY_DETECTORS_INDEX_MAPPING_FILE; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.ANOMALY_DETECTOR_JOBS_INDEX_MAPPING_FILE; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.ANOMALY_RESULTS_INDEX_MAPPING_FILE; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; +import com.google.common.base.Charsets; +import com.google.common.io.Resources; /** * This class manages creation of anomaly detector index. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDao.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDao.java index 727dafe7..d8a3a76a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDao.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModel.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModel.java index 9519f694..17e85ccb 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModel.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import com.google.gson.annotations.Expose; import com.google.gson.annotations.JsonAdapter; - import com.yahoo.sketches.kll.KllFloatsSketch; /** diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDe.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDe.java index a8c0ac72..a6812ab8 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDe.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDe.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -18,13 +18,12 @@ import java.lang.reflect.Type; import java.util.Base64; -import com.google.gson.JsonDeserializer; import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializer; import com.google.gson.JsonSerializationContext; - +import com.google.gson.JsonSerializer; import com.yahoo.memory.Memory; import com.yahoo.sketches.kll.KllFloatsSketch; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManager.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManager.java index de9bac74..00b4791d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManager.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManager.java @@ -22,8 +22,8 @@ import java.time.Instant; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Arrays; -import java.util.Iterator; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -40,9 +40,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - -import com.google.gson.Gson; - import org.elasticsearch.action.ActionListener; import org.elasticsearch.monitor.jvm.JvmService; @@ -54,6 +51,7 @@ import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; import com.amazon.randomcutforest.RandomCutForest; import com.amazon.randomcutforest.serialize.RandomCutForestSerDe; +import com.google.gson.Gson; /** * A facade managing ML operations and models. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelState.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelState.java index 6d6a61cf..acffed1d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelState.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelState.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResult.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResult.java index 81668128..8164fefc 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResult.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingModel.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingModel.java index 176f8c53..746d4354 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingModel.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResult.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResult.java index 9e4aa174..017a3cbb 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResult.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResult.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResult.java index b9e996bc..412e60c4 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResult.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java index 6155241c..0c3373df 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetector.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,9 +15,17 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; -import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; -import com.google.common.base.Objects; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder; + +import java.io.IOException; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import org.apache.logging.log4j.util.Strings; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.unit.TimeValue; @@ -30,16 +38,9 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.builder.SearchSourceBuilder; -import java.io.IOException; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; -import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder; +import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; +import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; +import com.google.common.base.Objects; /** * An AnomalyDetector is used to represent anomaly detection model(RCF) related parameters. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInput.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInput.java index 336092f4..45ccf963 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInput.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInput.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,17 +15,18 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; -import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; -import com.google.common.base.Objects; -import org.elasticsearch.common.xcontent.ToXContentObject; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentParser; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; import java.io.IOException; import java.time.Instant; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentParser; + +import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; +import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; +import com.google.common.base.Objects; /** * Input data needed to trigger anomaly detector. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJob.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJob.java index bf552941..30f36939 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJob.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJob.java @@ -15,20 +15,21 @@ package com.amazon.opendistroforelasticsearch.ad.model; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.DEFAULT_AD_JOB_LOC_DURATION_SECONDS; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.time.Instant; + +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentParser; + import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; import com.amazon.opendistroforelasticsearch.jobscheduler.spi.ScheduledJobParameter; import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.Schedule; import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.ScheduleParser; import com.google.common.base.Objects; -import org.elasticsearch.common.xcontent.ToXContentObject; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentParser; - -import java.io.IOException; -import java.time.Instant; - -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.DEFAULT_AD_JOB_LOC_DURATION_SECONDS; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; /** * Anomaly detector job. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResult.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResult.java index d0881e3b..282d7a3f 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResult.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,9 +15,12 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; -import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; -import com.google.common.base.Objects; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -25,12 +28,9 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import java.io.IOException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; - -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; +import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; +import com.google.common.base.Objects; /** * Include result returned from RCF model and feature data. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/Feature.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/Feature.java index a848cc1e..31c03ef5 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/Feature.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/Feature.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,9 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; -import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; -import com.google.common.base.Objects; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; + import org.apache.logging.log4j.util.Strings; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -25,9 +26,9 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.search.aggregations.AggregationBuilder; -import java.io.IOException; - -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; +import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; +import com.google.common.base.Objects; /** * Anomaly detector feature diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureData.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureData.java index 1bfa0208..b9f66ef1 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureData.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureData.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,15 +15,16 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; -import com.google.common.base.Objects; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; + import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; -import java.io.IOException; - -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; +import com.google.common.base.Objects; /** * Feature data used by RCF model. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfiguration.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfiguration.java index 2478cf11..8d0e1ede 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfiguration.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,17 +15,18 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import org.elasticsearch.common.xcontent.XContentBuilder; - import java.io.IOException; import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Locale; import java.util.Set; +import org.elasticsearch.common.xcontent.XContentBuilder; + +import com.amazon.opendistroforelasticsearch.ad.annotation.Generated; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + public class IntervalTimeConfiguration extends TimeConfiguration { private long interval; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/ModelProfile.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/ModelProfile.java index 94f47f83..71d61530 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/ModelProfile.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/ModelProfile.java @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + package com.amazon.opendistroforelasticsearch.ad.model; /* diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/TimeConfiguration.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/TimeConfiguration.java index a2b79096..e8a28768 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/TimeConfiguration.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/model/TimeConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import org.elasticsearch.common.xcontent.ToXContentObject; -import org.elasticsearch.common.xcontent.XContentParser; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; import java.io.IOException; import java.time.temporal.ChronoUnit; import java.util.Locale; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.common.xcontent.XContentParser; /** * TimeConfiguration represents the time configuration for a job which runs regularly. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/AbstractSearchAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/AbstractSearchAction.java index f1f86027..08c3e4b3 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/AbstractSearchAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/AbstractSearchAction.java @@ -15,10 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.google.common.collect.ImmutableList; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.getSourceContext; +import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -41,13 +44,10 @@ import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; -import java.io.IOException; -import java.util.List; - -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.getSourceContext; -import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS; -import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.google.common.collect.ImmutableList; /** * Abstract class to handle search request. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestAnomalyDetectorJobAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestAnomalyDetectorJobAction.java index 7bd8f628..5410b532 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestAnomalyDetectorJobAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestAnomalyDetectorJobAction.java @@ -15,12 +15,17 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; -import com.amazon.opendistroforelasticsearch.ad.rest.handler.IndexAnomalyDetectorJobActionHandler; -import com.google.common.collect.ImmutableList; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_PRIMARY_TERM; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_SEQ_NO; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.REFRESH; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.START_JOB; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.STOP_JOB; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.client.node.NodeClient; @@ -31,17 +36,12 @@ import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; -import java.io.IOException; -import java.util.List; -import java.util.Locale; - -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_PRIMARY_TERM; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_SEQ_NO; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.REFRESH; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.START_JOB; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.STOP_JOB; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; +import com.amazon.opendistroforelasticsearch.ad.rest.handler.IndexAnomalyDetectorJobActionHandler; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.google.common.collect.ImmutableList; /** * This class consists of the REST handler to handle request to start/stop AD job. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestDeleteAnomalyDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestDeleteAnomalyDetectorAction.java index 300141e7..b7b2f17c 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestDeleteAnomalyDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestDeleteAnomalyDetectorAction.java @@ -15,13 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.rest.handler.AnomalyDetectorActionHandler; -import com.google.common.collect.ImmutableList; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -38,11 +36,13 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.action.RestStatusToXContentListener; -import java.io.IOException; -import java.util.List; -import java.util.Locale; - -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.rest.handler.AnomalyDetectorActionHandler; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.google.common.collect.ImmutableList; /** * This class consists of the REST handler to delete anomaly detector. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestExecuteAnomalyDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestExecuteAnomalyDetectorAction.java index c710ba9f..55ff1296 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestExecuteAnomalyDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestExecuteAnomalyDetectorAction.java @@ -15,16 +15,16 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorRunner; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorExecutionInput; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; -import com.amazon.opendistroforelasticsearch.ad.transport.AnomalyResultAction; -import com.amazon.opendistroforelasticsearch.ad.transport.AnomalyResultRequest; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; -import com.google.common.collect.ImmutableList; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.MAX_ANOMALY_FEATURES; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.PREVIEW; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.RUN; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; @@ -48,16 +48,16 @@ import org.elasticsearch.rest.action.RestActionListener; import org.elasticsearch.rest.action.RestToXContentListener; -import java.io.IOException; -import java.util.List; -import java.util.Locale; - -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.MAX_ANOMALY_FEATURES; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.PREVIEW; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.RUN; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorRunner; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorExecutionInput; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.amazon.opendistroforelasticsearch.ad.transport.AnomalyResultAction; +import com.amazon.opendistroforelasticsearch.ad.transport.AnomalyResultRequest; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; +import com.google.common.collect.ImmutableList; /** * This class consists of the REST handler to handle request to detect data. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestGetAnomalyDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestGetAnomalyDetectorAction.java index 3c33e320..93994471 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestGetAnomalyDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestGetAnomalyDetectorAction.java @@ -15,21 +15,24 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.model.DetectorProfile; -import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Sets; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorProfileRunner; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX; +import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.PROFILE; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.TYPE; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.createXContentParser; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequest; @@ -47,21 +50,17 @@ import org.elasticsearch.rest.action.RestActions; import org.elasticsearch.rest.action.RestResponseListener; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import java.util.stream.Collectors; - -import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX; -import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.PROFILE; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.TYPE; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.createXContentParser; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorProfileRunner; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.model.DetectorProfile; +import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Sets; /** * This class consists of the REST handler to retrieve an anomaly detector. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestIndexAnomalyDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestIndexAnomalyDetectorAction.java index c40fd0e7..8629ec21 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestIndexAnomalyDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestIndexAnomalyDetectorAction.java @@ -15,13 +15,20 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.rest.handler.IndexAnomalyDetectorActionHandler; -import com.google.common.collect.ImmutableList; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.DETECTION_INTERVAL; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.DETECTION_WINDOW_DELAY; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.MAX_ANOMALY_DETECTORS; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.MAX_ANOMALY_FEATURES; +import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_PRIMARY_TERM; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_SEQ_NO; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.REFRESH; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.util.List; +import java.util.Locale; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -35,20 +42,13 @@ import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; -import java.io.IOException; -import java.util.List; -import java.util.Locale; - -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.DETECTION_INTERVAL; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.DETECTION_WINDOW_DELAY; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.MAX_ANOMALY_DETECTORS; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.MAX_ANOMALY_FEATURES; -import static com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings.REQUEST_TIMEOUT; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.DETECTOR_ID; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_PRIMARY_TERM; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.IF_SEQ_NO; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.REFRESH; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.rest.handler.IndexAnomalyDetectorActionHandler; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.google.common.collect.ImmutableList; /** * Rest handlers to create and update anomaly detector. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyDetectorAction.java index b7a84d25..f71f4705 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyDetectorAction.java @@ -15,11 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; - import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; + /** * This class consists of the REST handler to search anomaly detectors. */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyResultAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyResultAction.java index 40466f43..b4ddc0be 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyResultAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestSearchAnomalyResultAction.java @@ -15,11 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; - import static com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices.ALL_AD_RESULTS_INDEX_PATTERN; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; + /** * This class consists of the REST handler to search anomaly results. */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestStatsAnomalyDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestStatsAnomalyDetectorAction.java index 7f83106e..fe0bcf46 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestStatsAnomalyDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/RestStatsAnomalyDetectorAction.java @@ -15,39 +15,40 @@ package com.amazon.opendistroforelasticsearch.ad.rest; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStatsResponse; -import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; -import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodesAction; -import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsRequest; -import com.amazon.opendistroforelasticsearch.ad.util.MultiResponsesDelegateActionListener; -import com.google.common.collect.ImmutableList; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; +import static com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin.AD_BASE_URI; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.client.Client; import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; +import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; +import org.elasticsearch.rest.RestStatus; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import static com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin.AD_BASE_URI; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStatsResponse; +import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; +import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodesAction; +import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsRequest; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; +import com.amazon.opendistroforelasticsearch.ad.util.MultiResponsesDelegateActionListener; +import com.google.common.collect.ImmutableList; /** * RestStatsAnomalyDetectorAction consists of the REST handler to get the stats from the anomaly detector plugin. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AbstractActionHandler.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AbstractActionHandler.java index dc42a4c3..e8ccf40f 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AbstractActionHandler.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AbstractActionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.rest.handler; +import java.io.IOException; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.rest.BytesRestResponse; import org.elasticsearch.rest.RestChannel; -import java.io.IOException; - /** * Action handler to process REST request and handle failures. */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorActionHandler.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorActionHandler.java index 5aa5e013..7780ee58 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorActionHandler.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorActionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,8 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.rest.handler; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; +import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -29,10 +32,8 @@ import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestStatus; -import java.io.IOException; - -import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; /** * Common handler to process AD request. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorFunction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorFunction.java index c9422a23..4d97c43d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorFunction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/AnomalyDetectorFunction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorActionHandler.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorActionHandler.java index b28db4ee..d712967c 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorActionHandler.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorActionHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,10 +15,16 @@ package com.amazon.opendistroforelasticsearch.ad.rest.handler; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; +import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE; +import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS; + +import java.io.IOException; +import java.time.Instant; +import java.util.Arrays; +import java.util.Locale; +import java.util.stream.Collectors; + import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -47,15 +53,10 @@ import org.elasticsearch.rest.action.RestResponseListener; import org.elasticsearch.search.builder.SearchSourceBuilder; -import java.io.IOException; -import java.time.Instant; -import java.util.Arrays; -import java.util.Locale; -import java.util.stream.Collectors; - -import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE; -import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; /** * Anomaly detector REST action handler to process POST/PUT request. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorJobActionHandler.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorJobActionHandler.java index d2c278d2..be72172a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorJobActionHandler.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/rest/handler/IndexAnomalyDetectorJobActionHandler.java @@ -15,16 +15,18 @@ package com.amazon.opendistroforelasticsearch.ad.rest.handler; -import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; -import com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorAction; -import com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorRequest; -import com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorResponse; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.IntervalSchedule; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.Schedule; +import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE; +import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.createXContentParser; +import static org.elasticsearch.action.DocWriteResponse.Result.CREATED; +import static org.elasticsearch.action.DocWriteResponse.Result.UPDATED; +import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS; +import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; + +import java.io.IOException; +import java.time.Duration; +import java.time.Instant; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -43,17 +45,16 @@ import org.elasticsearch.rest.RestChannel; import org.elasticsearch.rest.RestStatus; -import java.io.IOException; -import java.time.Duration; -import java.time.Instant; - -import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE; -import static com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils.createXContentParser; -import static org.elasticsearch.action.DocWriteResponse.Result.CREATED; -import static org.elasticsearch.action.DocWriteResponse.Result.UPDATED; -import static org.elasticsearch.common.xcontent.ToXContent.EMPTY_PARAMS; -import static org.elasticsearch.common.xcontent.XContentParserUtils.ensureExpectedToken; +import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; +import com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorAction; +import com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorRequest; +import com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorResponse; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.IntervalSchedule; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.Schedule; /** * Anomaly detector job REST action handler to process POST/PUT request. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/AnomalyDetectorSettings.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/AnomalyDetectorSettings.java index 63262d9b..2e22dbe7 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/AnomalyDetectorSettings.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/AnomalyDetectorSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/EnabledSetting.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/EnabledSetting.java index 7b3be00d..5b0ce93f 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/EnabledSetting.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/settings/EnabledSetting.java @@ -1,25 +1,23 @@ /* - * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. */ package com.amazon.opendistroforelasticsearch.ad.settings; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; +import static java.util.Collections.unmodifiableMap; +import static org.elasticsearch.common.settings.Setting.Property.Dynamic; +import static org.elasticsearch.common.settings.Setting.Property.NodeScope; import java.util.ArrayList; import java.util.HashMap; @@ -27,9 +25,11 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import static java.util.Collections.unmodifiableMap; -import static org.elasticsearch.common.settings.Setting.Property.Dynamic; -import static org.elasticsearch.common.settings.Setting.Property.NodeScope; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Settings; public class EnabledSetting { diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStat.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStat.java index 6a6fa2a2..a5f5f228 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStat.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStat.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,11 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.stats; +import java.util.function.Supplier; + import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.SettableSupplier; -import java.util.function.Supplier; - /** * Class represents a stat the plugin keeps track of */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStats.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStats.java index 7672895e..2ed6098d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStats.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStats.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,12 +15,12 @@ package com.amazon.opendistroforelasticsearch.ad.stats; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; - import java.util.HashMap; import java.util.Map; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; + /** * This class is the main entry-point for access to the stats that the AD plugin keeps track of. */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponse.java index e256990c..786da34a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponse.java @@ -18,8 +18,6 @@ import java.io.IOException; import java.util.Map; -import com.amazon.opendistroforelasticsearch.ad.model.Mergeable; -import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodesResponse; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; @@ -27,6 +25,9 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.model.Mergeable; +import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodesResponse; + /** * ADStatsResponse contains logic to merge the node stats and cluster stats together and return them to user */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/StatNames.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/StatNames.java index e4c474ac..b68542f1 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/StatNames.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/StatNames.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplier.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplier.java index 6e87699e..cd6655d8 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplier.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplier.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexStatusSupplier.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexStatusSupplier.java index 78d29ef3..f99e68cd 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexStatusSupplier.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexStatusSupplier.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.stats.suppliers; -import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; - import java.util.function.Supplier; +import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; + /** * IndexStatusSupplier provides the status of an index as the value */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplier.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplier.java index 76cdcc77..d8cb4b66 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplier.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplier.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,7 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.stats.suppliers; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import static com.amazon.opendistroforelasticsearch.ad.ml.ModelState.DETECTOR_ID_KEY; +import static com.amazon.opendistroforelasticsearch.ad.ml.ModelState.MODEL_ID_KEY; +import static com.amazon.opendistroforelasticsearch.ad.ml.ModelState.MODEL_TYPE_KEY; import java.util.ArrayList; import java.util.Arrays; @@ -26,9 +28,7 @@ import java.util.function.Supplier; import java.util.stream.Collectors; -import static com.amazon.opendistroforelasticsearch.ad.ml.ModelState.DETECTOR_ID_KEY; -import static com.amazon.opendistroforelasticsearch.ad.ml.ModelState.MODEL_ID_KEY; -import static com.amazon.opendistroforelasticsearch.ad.ml.ModelState.MODEL_TYPE_KEY; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; /** * ModelsOnNodeSupplier provides a List of ModelStates info for the models the nodes contains diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplier.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplier.java index 69a7add2..c32794ba 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplier.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplier.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManager.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManager.java index 4e993c50..9eb5bbcc 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManager.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManager.java @@ -20,17 +20,12 @@ import java.time.Clock; import java.time.Duration; import java.time.Instant; -import java.util.Map; -import java.util.Optional; import java.util.AbstractMap.SimpleEntry; +import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; -import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -43,6 +38,11 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; +import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; + /** * ADStateManager is used by transport layer to manage AnomalyDetector object * and the number of partitions for a detector id. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeRequest.java index d8b85a81..6a7a7d67 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,12 +15,12 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; + import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import java.io.IOException; - /** * ADStatsNodeRequest to get a nodes stat */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeResponse.java index ac1c536a..10bbb57e 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; +import java.util.Map; + import org.elasticsearch.action.support.nodes.BaseNodeResponse; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; @@ -22,9 +25,6 @@ import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; -import java.io.IOException; -import java.util.Map; - /** * ADStatsNodeResponse */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesAction.java index cb664911..5260f503 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesResponse.java index d6ad8828..de4e523a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; +import java.util.List; + import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.nodes.BaseNodesResponse; import org.elasticsearch.cluster.ClusterName; @@ -24,9 +27,6 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; -import java.io.IOException; -import java.util.List; - /** * ADStatsNodesResponse consists of the aggregated responses from the nodes */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportAction.java index faa318e0..433a753e 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,21 +15,22 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.transport.TransportService; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.transport.TransportService; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; /** * ADStatsNodesTransportAction contains the logic to extract the stats from the nodes diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsRequest.java index d21422c8..5db717d0 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,15 +15,15 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - /** * ADStatsRequest implements a request to obtain stats about the AD plugin */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultAction.java index 2cb02d65..8408c6cc 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java index f0be2b3d..b3a19200 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ import java.io.IOException; import java.util.Locale; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.Strings; @@ -33,6 +32,7 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; public class AnomalyResultRequest extends ActionRequest implements ToXContentObject { diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultResponse.java index 972909ae..aea39b80 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.List; -import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.io.stream.InputStreamStreamInput; import org.elasticsearch.common.io.stream.OutputStreamStreamOutput; @@ -30,6 +29,8 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; + public class AnomalyResultResponse extends ActionResponse implements ToXContentObject { public static final String ANOMALY_GRADE_JSON_KEY = "anomalyGrade"; public static final String CONFIDENCE_JSON_KEY = "confidence"; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTransportAction.java index 5a779a21..5d6df1ca 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTransportAction.java @@ -23,30 +23,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; -import com.amazon.opendistroforelasticsearch.ad.cluster.HashRing; -import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.ClientException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.EndRunException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; -import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.ResourceNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.feature.SinglePointFeatures; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.ml.RcfResult; -import com.amazon.opendistroforelasticsearch.ad.ml.rcf.CombinedRcfResult; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; -import com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings; -import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; -import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; -import com.amazon.opendistroforelasticsearch.ad.util.ColdStartRunner; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; @@ -67,14 +43,38 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.NotSerializableExceptionWrapper; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.node.NodeClosedException; import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.ReceiveTimeoutTransportException; import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.IndexNotFoundException; + +import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; +import com.amazon.opendistroforelasticsearch.ad.cluster.HashRing; +import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.ClientException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.EndRunException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; +import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.ResourceNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.feature.SinglePointFeatures; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.ml.RcfResult; +import com.amazon.opendistroforelasticsearch.ad.ml.rcf.CombinedRcfResult; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; +import com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings; +import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; +import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; +import com.amazon.opendistroforelasticsearch.ad.util.ColdStartRunner; public class AnomalyResultTransportAction extends HandledTransportAction { diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/BackPressureRouting.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/BackPressureRouting.java index 08de0f0e..3846fab3 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/BackPressureRouting.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/BackPressureRouting.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronAction.java index d9df8c59..f752677f 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeRequest.java index a7d38e82..eab379ce 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,11 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; + import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.common.io.stream.StreamInput; -import java.io.IOException; - /** * Delete model represents the request to an individual node */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeResponse.java index a24ea896..ceb532d4 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronNodeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronRequest.java index 4165a0ab..53473eb5 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,12 +15,12 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; + import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; -import java.io.IOException; - /** * Request should be sent from the handler logic of transport delete detector API * diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronResponse.java index 4a6e4fca..26b64b51 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportAction.java index 8b6747b1..3d63f77c 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ import java.io.IOException; import java.util.List; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.nodes.TransportNodesAction; @@ -29,6 +27,9 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; + public class CronTransportAction extends TransportNodesAction { private ADStateManager transportStateManager; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorAction.java index 92f38909..fab65fb4 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorRequest.java index 910f9302..f9b78064 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import java.io.IOException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.common.Strings; @@ -28,6 +27,7 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; /** diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorTransportAction.java index 13ec6a3e..f580bf49 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteDetectorTransportAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,7 +15,8 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.cluster.DeleteDetector; +import java.io.IOException; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; @@ -37,7 +38,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import java.io.IOException; +import com.amazon.opendistroforelasticsearch.ad.cluster.DeleteDetector; public class DeleteDetectorTransportAction extends TransportMasterNodeAction { private static final Logger LOG = LogManager.getLogger(DeleteDetectorTransportAction.class); diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelAction.java index a46a01c2..d27a4a2d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeRequest.java index f008a126..2f14710a 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeResponse.java index fa33f2b7..d93e8cbe 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelNodeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelRequest.java index d4b2c145..42dcfafb 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -19,8 +19,6 @@ import java.io.IOException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.cluster.node.DiscoveryNode; @@ -30,6 +28,9 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; + /** * Request should be sent from the handler logic of transport delete detector API * diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelResponse.java index f91ecb26..a03d451f 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportAction.java index b7c35b10..3256b70e 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ import java.io.IOException; import java.util.List; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.FailedNodeException; @@ -31,6 +29,9 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; + public class DeleteModelTransportAction extends TransportNodesAction { private static final Logger LOG = LogManager.getLogger(DeleteModelTransportAction.class); diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeRequest.java index 7f25d397..7ba1b40d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeRequest.java @@ -15,15 +15,15 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; +import java.util.Set; + import org.elasticsearch.action.support.nodes.BaseNodeRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; -import java.io.IOException; -import java.util.Set; - /** * Class representing a nodes's profile request */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeResponse.java index df4c7cbb..517e68a2 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileNodeResponse.java @@ -15,6 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; +import java.util.Map; + import org.elasticsearch.action.support.nodes.BaseNodeResponse; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; @@ -22,9 +25,6 @@ import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; -import java.io.IOException; -import java.util.Map; - /** * Profile response on a node */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileRequest.java index 531312a1..5ff6c56c 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileRequest.java @@ -15,6 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.io.stream.StreamInput; @@ -22,10 +26,6 @@ import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - /** * implements a request to obtain profiles about an AD detector */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileResponse.java index cdfd79e8..713ba76b 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileResponse.java @@ -15,6 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.nodes.BaseNodesResponse; import org.elasticsearch.cluster.ClusterName; @@ -26,11 +31,6 @@ import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; import com.amazon.opendistroforelasticsearch.ad.model.ModelProfile; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - /** * This class consists of the aggregated responses from the nodes */ diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportAction.java index 5806c5d7..2154c938 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportAction.java @@ -15,23 +15,24 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.transport.TransportService; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.transport.TransportService; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; /** * This class contains the logic to extract the stats from the nodes diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultAction.java index a10451ee..baa2cbd8 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultRequest.java index d0b5d12d..ce43e0a1 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import java.io.IOException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.Strings; @@ -28,6 +27,7 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; public class RCFResultRequest extends ActionRequest implements ToXContentObject { diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultResponse.java index 8e5d6aba..e5938225 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTransportAction.java index 382c632c..c2b28058 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTransportAction.java @@ -15,11 +15,6 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; -import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.ActionListener; @@ -29,6 +24,11 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; +import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; +import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; + public class RCFResultTransportAction extends HandledTransportAction { private static final Logger LOG = LogManager.getLogger(RCFResultTransportAction.class); diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorAction.java index 78615197..60d00095 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorRequest.java index dbb98af7..f922bf53 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,8 +15,12 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; +import static org.elasticsearch.action.ValidateActions.addValidationError; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.Strings; @@ -27,11 +31,8 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import static org.elasticsearch.action.ValidateActions.addValidationError; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; public class StopDetectorRequest extends ActionRequest implements ToXContentObject { diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorResponse.java index a37a8220..9aca7b9d 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.io.stream.InputStreamStreamInput; import org.elasticsearch.common.io.stream.OutputStreamStreamOutput; @@ -23,10 +27,6 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - public class StopDetectorResponse extends ActionResponse implements ToXContentObject { public static final String SUCCESS_JSON_KEY = "success"; private boolean success; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorTransportAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorTransportAction.java index be542961..93786df7 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorTransportAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/StopDetectorTransportAction.java @@ -15,9 +15,6 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; @@ -33,6 +30,9 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; +import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; + public class StopDetectorTransportAction extends HandledTransportAction { private static final Logger LOG = LogManager.getLogger(StopDetectorTransportAction.class); diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultAction.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultAction.java index ee45a08c..7123ba64 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultAction.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultRequest.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultRequest.java index 66d99049..2f06d5c1 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultRequest.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import java.io.IOException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.common.Strings; @@ -28,6 +27,7 @@ import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; public class ThresholdResultRequest extends ActionRequest implements ToXContentObject { diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultResponse.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultResponse.java index 17e55436..b79bd339 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultResponse.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -17,13 +17,14 @@ import java.io.IOException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; + public class ThresholdResultResponse extends ActionResponse implements ToXContentObject { private double anomalyGrade; private double confidence; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandler.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandler.java index e9a970cc..49cd12d4 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandler.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandler.java @@ -15,11 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.transport.handler; -import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; -import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; -import com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +import java.util.Iterator; +import java.util.Locale; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.ExceptionsHelper; @@ -41,10 +41,11 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.threadpool.ThreadPool; -import java.util.Iterator; -import java.util.Locale; - -import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; +import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; +import com.amazon.opendistroforelasticsearch.ad.settings.AnomalyDetectorSettings; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; public class AnomalyResultHandler { private static final Logger LOG = LogManager.getLogger(AnomalyResultHandler.class); diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ClientUtil.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ClientUtil.java index cdfc4392..5a56d752 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ClientUtil.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ClientUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -25,18 +25,14 @@ import java.util.function.BiConsumer; import java.util.function.Function; -import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; - import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchTimeoutException; -import org.elasticsearch.action.ActionType; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.ActionType; import org.elasticsearch.action.LatchedActionListener; import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksAction; @@ -49,14 +45,17 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; - -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.tasks.TaskInfo; import org.elasticsearch.threadpool.ThreadPool; +import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; + public class ClientUtil { private volatile TimeValue requestTimeout; private Client client; diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunner.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunner.java index 00dc757f..377c0918 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunner.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtils.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtils.java index 9958af60..73340b89 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtils.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.util; +import java.util.List; +import java.util.Optional; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; @@ -24,9 +27,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.service.ClusterService; -import java.util.List; -import java.util.Optional; - public class IndexUtils { /** * Status string of index that does not exist diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtils.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtils.java index e5709697..8790b52b 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtils.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,8 +15,18 @@ package com.amazon.opendistroforelasticsearch.ad.util; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.Feature; +import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.QUERY_PARAM_PERIOD_END; +import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.QUERY_PARAM_PERIOD_START; +import static org.elasticsearch.search.aggregations.AggregationBuilders.dateRange; +import static org.elasticsearch.search.aggregations.AggregatorFactories.VALID_AGG_NAME; + +import java.io.IOException; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Matcher; + import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -32,17 +42,8 @@ import org.elasticsearch.search.aggregations.bucket.range.DateRangeAggregationBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder; -import java.io.IOException; -import java.time.Instant; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.regex.Matcher; - -import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.QUERY_PARAM_PERIOD_END; -import static com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector.QUERY_PARAM_PERIOD_START; -import static org.elasticsearch.search.aggregations.AggregationBuilders.dateRange; -import static org.elasticsearch.search.aggregations.AggregatorFactories.VALID_AGG_NAME; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.Feature; /** * Parsing utility functions. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtils.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtils.java index 057eeec7..5032a898 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtils.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,9 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.util; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.Feature; -import com.google.common.collect.ImmutableMap; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; @@ -29,10 +31,9 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; -import java.io.IOException; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.Feature; +import com.google.common.collect.ImmutableMap; /** * Utility functions for REST handlers. diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/Throttler.java b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/Throttler.java index 4c5ebaed..88fd6f57 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/Throttler.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/ad/util/Throttler.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -12,6 +12,7 @@ * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ + package com.amazon.opendistroforelasticsearch.ad.util; import java.time.Clock; @@ -20,6 +21,7 @@ import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; + import org.elasticsearch.action.ActionRequest; /** diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/AbstractADTest.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/AbstractADTest.java index 728f4316..9cb23a24 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/AbstractADTest.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/AbstractADTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -21,8 +21,8 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.core.Logger; import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.Logger; import org.apache.logging.log4j.core.appender.AbstractAppender; import org.apache.logging.log4j.core.layout.PatternLayout; import org.apache.logging.log4j.util.StackLocatorUtil; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunnerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunnerTests.java index 45b23ea0..8be5cdb5 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunnerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorJobRunnerTests.java @@ -15,17 +15,25 @@ package com.amazon.opendistroforelasticsearch.ad; -import com.amazon.opendistroforelasticsearch.ad.common.exception.EndRunException; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; -import com.amazon.opendistroforelasticsearch.ad.transport.handler.AnomalyResultHandler; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.JobExecutionContext; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.LockModel; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.ScheduledJobParameter; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.IntervalSchedule; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.Schedule; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.utils.LockService; +import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Collections; +import java.util.Iterator; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadFactory; + import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; @@ -53,24 +61,17 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Collections; -import java.util.Iterator; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadFactory; - -import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import com.amazon.opendistroforelasticsearch.ad.common.exception.EndRunException; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; +import com.amazon.opendistroforelasticsearch.ad.transport.handler.AnomalyResultHandler; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.JobExecutionContext; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.LockModel; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.ScheduledJobParameter; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.IntervalSchedule; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.Schedule; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.utils.LockService; public class AnomalyDetectorJobRunnerTests extends AbstractADTest { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRestTestCase.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRestTestCase.java index 32dc442b..8e470699 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRestTestCase.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/AnomalyDetectorRestTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,11 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import static org.apache.http.entity.ContentType.APPLICATION_JSON; +import static org.elasticsearch.common.xcontent.json.JsonXContent.jsonXContent; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; + import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; import org.apache.http.entity.StringEntity; @@ -41,12 +43,11 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.test.rest.ESRestTestCase; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; - -import static org.apache.http.entity.ContentType.APPLICATION_JSON; -import static org.elasticsearch.common.xcontent.json.JsonXContent.jsonXContent; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; public abstract class AnomalyDetectorRestTestCase extends ESRestTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/TestHelpers.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/TestHelpers.java index 4c64fabd..3b94ea13 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/TestHelpers.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/TestHelpers.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,17 +15,25 @@ package com.amazon.opendistroforelasticsearch.ad; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorExecutionInput; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; -import com.amazon.opendistroforelasticsearch.ad.model.Feature; -import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; -import com.amazon.opendistroforelasticsearch.ad.model.TimeConfiguration; -import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.IntervalSchedule; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import static org.elasticsearch.cluster.node.DiscoveryNodeRole.BUILT_IN_ROLES; +import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder; +import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; +import static org.elasticsearch.test.ESTestCase.randomAlphaOfLength; +import static org.elasticsearch.test.ESTestCase.randomDouble; +import static org.elasticsearch.test.ESTestCase.randomInt; +import static org.elasticsearch.test.ESTestCase.randomLong; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.when; + +import java.io.IOException; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Callable; +import java.util.function.Consumer; + import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.entity.ContentType; @@ -87,24 +95,17 @@ import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.threadpool.ThreadPool; -import java.io.IOException; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.function.Consumer; - -import static org.elasticsearch.cluster.node.DiscoveryNodeRole.BUILT_IN_ROLES; -import static org.elasticsearch.index.query.AbstractQueryBuilder.parseInnerQueryBuilder; -import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; -import static org.elasticsearch.test.ESTestCase.randomAlphaOfLength; -import static org.elasticsearch.test.ESTestCase.randomDouble; -import static org.elasticsearch.test.ESTestCase.randomInt; -import static org.elasticsearch.test.ESTestCase.randomLong; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorExecutionInput; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetectorJob; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; +import com.amazon.opendistroforelasticsearch.ad.model.Feature; +import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; +import com.amazon.opendistroforelasticsearch.ad.model.TimeConfiguration; +import com.amazon.opendistroforelasticsearch.jobscheduler.spi.schedule.IntervalSchedule; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; public class TestHelpers { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerServiceTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerServiceTests.java index 218fee88..b96e3158 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerServiceTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/ADCircuitBreakerServiceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.breaker; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.mockito.Mockito.when; + import org.elasticsearch.monitor.jvm.JvmService; import org.elasticsearch.monitor.jvm.JvmStats; import org.junit.Before; @@ -23,13 +30,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.mockito.Mockito.when; - public class ADCircuitBreakerServiceTests { @InjectMocks diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreakerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreakerTests.java index 133a603a..76811096 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreakerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/breaker/MemoryCircuitBreakerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.breaker; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.mockito.Mockito.when; + import org.elasticsearch.monitor.jvm.JvmService; import org.elasticsearch.monitor.jvm.JvmStats; import org.junit.Before; @@ -22,10 +26,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.mockito.Mockito.when; - public class MemoryCircuitBreakerTests { @Mock diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListenerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListenerTests.java index 8305b10d..b9958356 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListenerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADClusterEventListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,13 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.cluster; +import static java.util.Collections.emptyMap; +import static java.util.Collections.emptySet; import static org.elasticsearch.cluster.node.DiscoveryNodeRole.BUILT_IN_ROLES; import static org.elasticsearch.test.ClusterServiceUtils.createClusterService; - +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Matchers.any; import java.util.HashMap; import java.util.HashSet; @@ -29,14 +30,7 @@ import java.util.Set; import java.util.concurrent.CountDownLatch; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; - -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; - +import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -45,12 +39,16 @@ import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.gateway.GatewayService; -import org.elasticsearch.Version; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; + public class ADClusterEventListenerTests extends AbstractADTest { private final String masterNodeId = "masterNode"; private final String dataNode1Id = "dataNode1"; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaDataTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaDataTests.java index 15f50dd7..43938eab 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaDataTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/ADMetaDataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -23,8 +23,6 @@ import java.util.Map; import java.util.Set; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.NamedDiff; import org.elasticsearch.cluster.metadata.MetaData; @@ -42,6 +40,8 @@ import org.elasticsearch.common.xcontent.XContentType; import org.junit.Before; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCronTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCronTests.java index 2772cd1b..30b21187 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCronTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DailyCronTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -26,14 +26,15 @@ import java.time.Duration; import java.util.Arrays; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Client; -import org.elasticsearch.index.reindex.DeleteByQueryAction; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.reindex.BulkByScrollResponse; +import org.elasticsearch.index.reindex.DeleteByQueryAction; + +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; public class DailyCronTests extends AbstractADTest { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetectorTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetectorTests.java index 55cb91ce..f2ec3da5 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetectorTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/DeleteDetectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import java.util.HashSet; import java.util.Set; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Client; @@ -44,6 +43,8 @@ import org.junit.After; import org.junit.Before; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; + public class DeleteDetectorTests extends AbstractADTest { private Client client; private ClusterService clusterService; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HashRingTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HashRingTests.java index 571f6d13..5797d404 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HashRingTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HashRingTests.java @@ -16,23 +16,18 @@ package com.amazon.opendistroforelasticsearch.ad.cluster; import static java.util.Collections.emptyMap; - import static org.elasticsearch.cluster.node.DiscoveryNodeRole.BUILT_IN_ROLES; import static org.elasticsearch.test.ClusterServiceUtils.createClusterService; import static org.elasticsearch.test.ClusterServiceUtils.setState; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.util.List; -import java.util.Map; -import java.util.Optional; import java.time.Clock; import java.util.ArrayList; import java.util.HashMap; - -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; @@ -46,6 +41,10 @@ import org.junit.Before; import org.junit.BeforeClass; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; + public class HashRingTests extends AbstractADTest { private ClusterService clusterService; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HourlyCronTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HourlyCronTests.java index 9060845d..60de33ad 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HourlyCronTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/HourlyCronTests.java @@ -16,7 +16,6 @@ package com.amazon.opendistroforelasticsearch.ad.cluster; import static org.mockito.ArgumentMatchers.any; - import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; @@ -26,13 +25,6 @@ import java.util.Collections; import java.util.HashMap; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.transport.CronAction; -import com.amazon.opendistroforelasticsearch.ad.transport.CronNodeResponse; -import com.amazon.opendistroforelasticsearch.ad.transport.CronResponse; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchException; @@ -48,6 +40,13 @@ import test.com.amazon.opendistroforelasticsearch.ad.util.ClusterCreation; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.transport.CronAction; +import com.amazon.opendistroforelasticsearch.ad.transport.CronNodeResponse; +import com.amazon.opendistroforelasticsearch.ad.transport.CronResponse; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; + public class HourlyCronTests extends AbstractADTest { enum HourlyCronTestExecutionMode { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListenerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListenerTests.java index 435c5e58..7e0019d7 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListenerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/cluster/MasterEventListenerTests.java @@ -18,20 +18,15 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.mockito.ArgumentMatchers.any; import java.time.Clock; import java.util.Arrays; import java.util.HashMap; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; - import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.component.LifecycleListener; @@ -40,6 +35,11 @@ import org.elasticsearch.threadpool.ThreadPool; import org.junit.Before; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; + public class MasterEventListenerTests extends AbstractADTest { private ClusterService clusterService; private ThreadPool threadPool; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/JsonPathNotFoundException.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/JsonPathNotFoundException.java index 571f6ba8..f86c8031 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/JsonPathNotFoundException.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/JsonPathNotFoundException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededExceptionTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededExceptionTests.java index 2d544330..da4f9815 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededExceptionTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/common/exception/LimitExceededExceptionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,10 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.common.exception; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.Test; + public class LimitExceededExceptionTests { @Test diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolatorTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolatorTests.java index 639ec1cb..226941bb 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolatorTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/IntegerSensitiveSingleFeatureLinearUniformInterpolatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ package com.amazon.opendistroforelasticsearch.ad.dataprocessor; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import junitparams.JUnitParamsRunner; @@ -24,8 +26,6 @@ import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.assertTrue; - @RunWith(JUnitParamsRunner.class) public class IntegerSensitiveSingleFeatureLinearUniformInterpolatorTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolatorTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolatorTests.java index a711b483..242f7a68 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolatorTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/LinearUniformInterpolatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ package com.amazon.opendistroforelasticsearch.ad.dataprocessor; +import static org.junit.Assert.assertArrayEquals; + import java.util.Arrays; import java.util.Collection; @@ -24,8 +26,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import static org.junit.Assert.assertArrayEquals; - @RunWith(Parameterized.class) public class LinearUniformInterpolatorTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolatorTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolatorTests.java index 54aa33a5..1be6fcb4 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolatorTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/dataprocessor/SingleFeatureLinearUniformInterpolatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ package com.amazon.opendistroforelasticsearch.ad.dataprocessor; +import static org.junit.Assert.assertArrayEquals; + import java.util.Arrays; import java.util.Collection; @@ -24,8 +26,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -import static org.junit.Assert.assertArrayEquals; - @RunWith(Parameterized.class) public class SingleFeatureLinearUniformInterpolatorTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/e2e/DetectionResultEvalutationIT.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/e2e/DetectionResultEvalutationIT.java index 076f4d83..e52d0352 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/e2e/DetectionResultEvalutationIT.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/e2e/DetectionResultEvalutationIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -29,13 +29,14 @@ import java.util.Map.Entry; import java.util.Set; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import org.elasticsearch.client.Request; import org.elasticsearch.client.RestClient; import org.elasticsearch.test.rest.ESRestTestCase; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + public class DetectionResultEvalutationIT extends ESRestTestCase { public void testDataset() throws Exception { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManagerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManagerTests.java index b7c7d8f3..b5286d50 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManagerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeatureManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,23 @@ package com.amazon.opendistroforelasticsearch.ad.feature; +import static java.util.Arrays.asList; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.argThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import java.io.IOException; import java.time.Clock; import java.time.Duration; @@ -26,46 +43,25 @@ import java.util.Map.Entry; import java.util.Optional; -import com.amazon.opendistroforelasticsearch.ad.dataprocessor.Interpolator; -import com.amazon.opendistroforelasticsearch.ad.dataprocessor.LinearUniformInterpolator; -import com.amazon.opendistroforelasticsearch.ad.dataprocessor.SingleFeatureLinearUniformInterpolator; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; -import com.amazon.opendistroforelasticsearch.ad.transport.ADStateManager; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.elasticsearch.action.ActionListener; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; - import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import com.amazon.opendistroforelasticsearch.ad.dataprocessor.Interpolator; +import com.amazon.opendistroforelasticsearch.ad.dataprocessor.LinearUniformInterpolator; +import com.amazon.opendistroforelasticsearch.ad.dataprocessor.SingleFeatureLinearUniformInterpolator; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; +import com.amazon.opendistroforelasticsearch.ad.transport.ADStateManager; import com.amazon.opendistroforelasticsearch.ad.util.ArrayEqMatcher; -import static java.util.Arrays.asList; -import static java.util.Optional.empty; -import static java.util.Optional.of; -import static java.util.Optional.ofNullable; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.argThat; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - @RunWith(JUnitParamsRunner.class) public class FeatureManagerTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeaturesTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeaturesTests.java index c6ae98e9..99366b1e 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeaturesTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/FeaturesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ package com.amazon.opendistroforelasticsearch.ad.feature; +import static org.junit.Assert.assertEquals; + import java.util.AbstractMap.SimpleEntry; import java.util.Arrays; import java.util.List; @@ -26,8 +28,6 @@ import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; - @RunWith(JUnitParamsRunner.class) public class FeaturesTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDaoTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDaoTests.java index d34fc6dd..569d28e9 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDaoTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/feature/SearchFeatureDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,31 +15,37 @@ package com.amazon.opendistroforelasticsearch.ad.feature; +import static java.util.Arrays.asList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import java.time.temporal.ChronoUnit; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.function.BiConsumer; -import com.amazon.opendistroforelasticsearch.ad.dataprocessor.Interpolator; -import com.amazon.opendistroforelasticsearch.ad.dataprocessor.LinearUniformInterpolator; -import com.amazon.opendistroforelasticsearch.ad.dataprocessor.SingleFeatureLinearUniformInterpolator; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; -import com.amazon.opendistroforelasticsearch.ad.transport.ADStateManager; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; -import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.apache.lucene.search.TotalHits; - import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.search.MultiSearchRequest; @@ -56,46 +62,35 @@ import org.elasticsearch.script.TemplateScript.Factory; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; -import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.Aggregation; +import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation; import org.elasticsearch.search.aggregations.metrics.InternalTDigestPercentiles; import org.elasticsearch.search.aggregations.metrics.Max; import org.elasticsearch.search.aggregations.metrics.Percentile; import org.elasticsearch.search.builder.SearchSourceBuilder; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; - import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; - import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import static java.util.Arrays.asList; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import static org.mockito.Mockito.mock; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import com.amazon.opendistroforelasticsearch.ad.dataprocessor.Interpolator; +import com.amazon.opendistroforelasticsearch.ad.dataprocessor.LinearUniformInterpolator; +import com.amazon.opendistroforelasticsearch.ad.dataprocessor.SingleFeatureLinearUniformInterpolator; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.IntervalTimeConfiguration; +import com.amazon.opendistroforelasticsearch.ad.transport.ADStateManager; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; +import com.amazon.opendistroforelasticsearch.ad.util.ParseUtils; @PowerMockIgnore("javax.management.*") @RunWith(PowerMockRunner.class) diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndicesTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndicesTests.java index 4faabe91..3f35f3a5 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndicesTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/indices/AnomalyDetectionIndicesTests.java @@ -15,12 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.indices; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; -import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.common.settings.Settings; @@ -32,9 +30,11 @@ import org.elasticsearch.test.ESIntegTestCase; import org.junit.Before; -import java.io.IOException; -import java.util.Collection; -import java.util.Collections; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; +import com.amazon.opendistroforelasticsearch.ad.util.RestHandlerUtils; public class AnomalyDetectionIndicesTests extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDaoTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDaoTests.java index 42e13233..618d1254 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDaoTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/CheckpointDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,18 @@ package com.amazon.opendistroforelasticsearch.ad.ml; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -23,7 +35,6 @@ import java.util.Set; import java.util.function.BiConsumer; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; @@ -32,28 +43,15 @@ import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.client.Client; - import org.junit.Before; import org.junit.Test; - import org.mockito.Answers; import org.mockito.ArgumentCaptor; import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; public class CheckpointDaoTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModelTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModelTests.java index 7eba6dd3..4037565a 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModelTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/HybridThresholdingModelTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,20 +15,19 @@ package com.amazon.opendistroforelasticsearch.ad.ml; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Arrays; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.apache.commons.math3.distribution.NormalDistribution; - import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - @RunWith(JUnitParamsRunner.class) public class HybridThresholdingModelTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDeTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDeTests.java index 7cf533f4..6ff19438 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDeTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/KllFloatsSketchSerDeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.ml; -import java.util.Random; +import static org.junit.Assert.assertEquals; -import com.google.gson.Gson; +import java.util.Random; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import com.google.gson.Gson; public class KllFloatsSketchSerDeTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManagerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManagerTests.java index a591394b..8120c7fa 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManagerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ModelManagerTests.java @@ -15,25 +15,35 @@ package com.amazon.opendistroforelasticsearch.ad.ml; +import static java.util.Arrays.asList; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyObject; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; + import java.time.Clock; import java.time.Duration; import java.time.Instant; -import java.util.Collections; -import java.util.List; import java.util.AbstractMap.SimpleEntry; import java.util.AbstractMap.SimpleImmutableEntry; +import java.util.Collections; +import java.util.List; import java.util.Map.Entry; import java.util.Optional; +import java.util.Random; import java.util.stream.Collectors; import java.util.stream.Stream; -import java.util.Random; - -import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.ResourceNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.ml.rcf.CombinedRcfResult; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; -import com.google.gson.Gson; import junitparams.JUnitParamsRunner; import junitparams.Parameters; @@ -42,43 +52,27 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.monitor.jvm.JvmService; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; - import org.mockito.Answers; import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; - import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.ResourceNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.ml.rcf.CombinedRcfResult; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.util.DiscoveryNodeFilterer; import com.amazon.randomcutforest.RandomCutForest; import com.amazon.randomcutforest.serialize.RandomCutForestSerDe; - -import static java.util.Arrays.asList; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; +import com.google.gson.Gson; @PowerMockIgnore("javax.management.*") @RunWith(PowerMockRunner.class) diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResultTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResultTests.java index d83f9cc0..7720f929 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResultTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/RcfResultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.ml; +import static org.junit.Assert.assertEquals; + import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; - @RunWith(JUnitParamsRunner.class) public class RcfResultTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResultTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResultTests.java index e8b3debe..a02410ae 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResultTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/ThresholdingResultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.ml; +import static org.junit.Assert.assertEquals; + import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; - @RunWith(JUnitParamsRunner.class) public class ThresholdingResultTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResultTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResultTests.java index 73450f01..f1fd737c 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResultTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/ml/rcf/CombinedRcfResultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.ml.rcf; +import static org.junit.Assert.assertEquals; + import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; - @RunWith(JUnitParamsRunner.class) public class CombinedRcfResultTests { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInputTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInputTests.java index 38edac6f..2c4917bf 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInputTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorExecutionInputTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,15 +15,16 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.test.ESTestCase; - import java.io.IOException; import java.time.Instant; import java.time.temporal.ChronoUnit; import java.util.Locale; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.test.ESTestCase; + +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; + public class AnomalyDetectorExecutionInputTests extends ESTestCase { public void testParseAnomalyDetectorExecutionInput() throws IOException { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJobTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJobTests.java index 4eded27f..ecf58ec8 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJobTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorJobTests.java @@ -15,12 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import java.io.IOException; +import java.util.Locale; + import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.test.ESTestCase; -import java.io.IOException; -import java.util.Locale; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; public class AnomalyDetectorJobTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java index 1b8c667a..434ef316 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyDetectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,18 +15,19 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import java.io.IOException; +import java.time.Instant; +import java.time.temporal.ChronoUnit; +import java.util.Locale; + import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.index.query.MatchAllQueryBuilder; import org.elasticsearch.test.ESTestCase; -import java.io.IOException; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.Locale; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; public class AnomalyDetectorTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResultTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResultTests.java index 964508d2..9d057a5a 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResultTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/AnomalyResultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,12 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import java.io.IOException; +import java.util.Locale; + import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.test.ESTestCase; -import java.io.IOException; -import java.util.Locale; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; public class AnomalyResultTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureDataTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureDataTests.java index 527a3aca..96f13468 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureDataTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureDataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,12 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import java.io.IOException; +import java.util.Locale; + import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.test.ESTestCase; -import java.io.IOException; -import java.util.Locale; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; public class FeatureDataTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureTests.java index 624d8fa1..41e71266 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/FeatureTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,12 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import java.io.IOException; +import java.util.Locale; + import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.test.ESTestCase; -import java.io.IOException; -import java.util.Locale; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; public class FeatureTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfigurationTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfigurationTests.java index 9359fb2d..2fd735f2 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfigurationTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/model/IntervalTimeConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,15 +15,16 @@ package com.amazon.opendistroforelasticsearch.ad.model; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.test.ESTestCase; - import java.io.IOException; import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Locale; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.test.ESTestCase; + +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; + public class IntervalTimeConfigurationTests extends ESTestCase { public void testParseIntervalSchedule() throws IOException { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/rest/AnomalyDetectorRestApiIT.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/rest/AnomalyDetectorRestApiIT.java index d502d717..af079ab3 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/rest/AnomalyDetectorRestApiIT.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/rest/AnomalyDetectorRestApiIT.java @@ -15,6 +15,28 @@ package com.amazon.opendistroforelasticsearch.ad.rest; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.AD_BASE_PREVIEW_URI; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomAnomalyDetectorWithEmptyFeature; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomFeature; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomIntervalTimeConfiguration; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomQuery; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomUiMetadata; +import static org.hamcrest.Matchers.containsString; + +import java.io.IOException; +import java.time.Instant; +import java.util.Map; + +import org.apache.http.entity.ContentType; +import org.apache.http.nio.entity.NStringEntity; +import org.elasticsearch.client.Response; +import org.elasticsearch.client.ResponseException; +import org.elasticsearch.common.UUIDs; +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.search.builder.SearchSourceBuilder; + import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorRestTestCase; import com.amazon.opendistroforelasticsearch.ad.TestHelpers; @@ -26,27 +48,6 @@ import com.amazon.opendistroforelasticsearch.ad.settings.EnabledSetting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import org.apache.http.entity.ContentType; -import org.apache.http.nio.entity.NStringEntity; -import org.elasticsearch.client.Response; -import org.elasticsearch.client.ResponseException; -import org.elasticsearch.common.UUIDs; -import org.elasticsearch.common.xcontent.ToXContentObject; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.search.builder.SearchSourceBuilder; - -import java.io.IOException; -import java.time.Instant; -import java.util.Map; - -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.AD_BASE_PREVIEW_URI; -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomAnomalyDetectorWithEmptyFeature; -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomFeature; -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomIntervalTimeConfiguration; -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomQuery; -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomUiMetadata; -import static org.hamcrest.Matchers.containsString; public class AnomalyDetectorRestApiIT extends AnomalyDetectorRestTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatTests.java index 1111561a..b1955583 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,12 +15,13 @@ package com.amazon.opendistroforelasticsearch.ad.stats; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.SettableSupplier; +import java.util.function.Supplier; + import org.elasticsearch.test.ESTestCase; import org.junit.Test; -import java.util.function.Supplier; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.SettableSupplier; public class ADStatTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponseTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponseTests.java index eaaa9576..2150920f 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponseTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsResponseTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,8 +15,12 @@ package com.amazon.opendistroforelasticsearch.ad.stats; -import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodeResponse; -import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodesResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -25,11 +29,8 @@ import org.elasticsearch.test.ESTestCase; import org.junit.Test; -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodeResponse; +import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsNodesResponse; public class ADStatsResponseTests extends ESTestCase { @Test diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsTests.java index 3454da1e..703f0c69 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/ADStatsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,20 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.stats; -import com.amazon.opendistroforelasticsearch.ad.ml.HybridThresholdingModel; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelState; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.IndexStatusSupplier; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.ModelsOnNodeSupplier; -import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; -import com.amazon.randomcutforest.RandomCutForest; -import org.elasticsearch.test.ESTestCase; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.time.Clock; import java.util.ArrayList; @@ -39,9 +28,20 @@ import java.util.Map; import java.util.Set; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import org.elasticsearch.test.ESTestCase; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import com.amazon.opendistroforelasticsearch.ad.ml.HybridThresholdingModel; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelState; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.IndexStatusSupplier; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.ModelsOnNodeSupplier; +import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; +import com.amazon.randomcutforest.RandomCutForest; public class ADStatsTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplierTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplierTests.java index 344c32bd..c571fa7d 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplierTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/CounterSupplierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexSupplierTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexSupplierTests.java index a0d80bf8..863dc943 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexSupplierTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/IndexSupplierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,13 +15,14 @@ package com.amazon.opendistroforelasticsearch.ad.stats.suppliers; -import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import org.elasticsearch.test.ESTestCase; import org.junit.Before; import org.junit.Test; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; public class IndexSupplierTests extends ESTestCase { private IndexUtils indexUtils; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplierTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplierTests.java index d515842c..a4937553 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplierTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/ModelsOnNodeSupplierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,25 +15,26 @@ package com.amazon.opendistroforelasticsearch.ad.stats.suppliers; -import com.amazon.opendistroforelasticsearch.ad.ml.HybridThresholdingModel; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelState; -import com.amazon.randomcutforest.RandomCutForest; -import org.elasticsearch.test.ESTestCase; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; +import static com.amazon.opendistroforelasticsearch.ad.stats.suppliers.ModelsOnNodeSupplier.MODEL_STATE_STAT_KEYS; +import static org.mockito.Mockito.when; import java.time.Clock; -import java.util.List; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import static com.amazon.opendistroforelasticsearch.ad.stats.suppliers.ModelsOnNodeSupplier.MODEL_STATE_STAT_KEYS; -import static org.mockito.Mockito.when; +import org.elasticsearch.test.ESTestCase; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; + +import com.amazon.opendistroforelasticsearch.ad.ml.HybridThresholdingModel; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelState; +import com.amazon.randomcutforest.RandomCutForest; public class ModelsOnNodeSupplierTests extends ESTestCase { private RandomCutForest rcf; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplierTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplierTests.java index 25235b8c..05b902a8 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplierTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/stats/suppliers/SettableSupplierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java index 1cce2aae..a088ec39 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStateManagerTests.java @@ -15,39 +15,29 @@ package com.amazon.opendistroforelasticsearch.ad.transport; +import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.when; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verifyZeroInteractions; -import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; +import static org.mockito.Mockito.when; import java.io.IOException; import java.time.Clock; import java.time.Duration; import java.time.Instant; +import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Arrays; import java.util.Collections; -import java.util.stream.IntStream; -import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.IntStream; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; -import com.amazon.opendistroforelasticsearch.ad.util.Throttler; -import com.google.common.collect.ImmutableMap; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.client.Client; -import org.elasticsearch.index.get.GetResult; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.search.SearchModule; -import org.elasticsearch.test.ESTestCase; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; @@ -55,10 +45,21 @@ import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.index.get.GetResult; +import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.search.SearchModule; +import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; import org.junit.Before; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; +import com.amazon.opendistroforelasticsearch.ad.util.Throttler; +import com.google.common.collect.ImmutableMap; + public class ADStateManagerTests extends ESTestCase { private ADStateManager stateManager; private ModelManager modelManager; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsIT.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsIT.java index 52496683..a47f436b 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsIT.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,14 +15,15 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.ESIntegTestCase; - import java.util.Collection; import java.util.Collections; import java.util.concurrent.ExecutionException; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.test.ESIntegTestCase; + +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; + @ESIntegTestCase.ClusterScope(transportClientRatio = 0.9) public class ADStatsIT extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportActionTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportActionTests.java index d632a0e6..49fd78c8 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportActionTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsNodesTransportActionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,15 +15,15 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStat; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.IndexStatusSupplier; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.ModelsOnNodeSupplier; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; -import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; -import com.amazon.opendistroforelasticsearch.ad.util.Throttler; +import static org.mockito.Mockito.mock; + +import java.time.Clock; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.Settings; @@ -33,14 +33,15 @@ import org.junit.Before; import org.junit.Test; -import java.time.Clock; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static org.mockito.Mockito.mock; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStat; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.IndexStatusSupplier; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.ModelsOnNodeSupplier; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; +import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; +import com.amazon.opendistroforelasticsearch.ad.util.Throttler; public class ADStatsNodesTransportActionTests extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsTests.java index a119ee7b..87af960e 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ADStatsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,8 +15,19 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; +import static java.util.Collections.emptyMap; +import static java.util.Collections.emptySet; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import org.elasticsearch.Version; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.cluster.ClusterName; @@ -30,20 +41,11 @@ import org.elasticsearch.test.ESTestCase; import org.junit.Before; import org.junit.Test; -import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; -import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; public class ADStatsTests extends ESTestCase { String node1, nodeName1, clusterName; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTests.java index d43e61e2..87ca0ea3 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/AnomalyResultTests.java @@ -18,27 +18,27 @@ import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.createIndexBlockedState; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.CoreMatchers.startsWith; +import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.anyDouble; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyLong; -import static org.mockito.Mockito.anyDouble; -import static org.mockito.Mockito.eq; import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; +import static org.mockito.Mockito.same; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; -import static org.mockito.Mockito.same; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.IOException; import java.time.Clock; @@ -52,36 +52,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; - -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.cluster.HashRing; -import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.EndRunException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.ResourceNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.feature.SinglePointFeatures; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.ml.RcfResult; -import com.amazon.opendistroforelasticsearch.ad.ml.ThresholdingResult; -import com.amazon.opendistroforelasticsearch.ad.ml.rcf.CombinedRcfResult; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; -import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStat; -import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; -import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; -import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; -import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; -import com.amazon.opendistroforelasticsearch.ad.util.ColdStartRunner; -import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; -import com.amazon.opendistroforelasticsearch.ad.util.Throttler; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequestValidationException; @@ -119,10 +89,39 @@ import org.junit.Before; import org.junit.BeforeClass; -import com.google.gson.JsonElement; - import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; +import com.amazon.opendistroforelasticsearch.ad.cluster.HashRing; +import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.EndRunException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.InternalFailure; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.ResourceNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonName; +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.feature.SinglePointFeatures; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.ml.RcfResult; +import com.amazon.opendistroforelasticsearch.ad.ml.ThresholdingResult; +import com.amazon.opendistroforelasticsearch.ad.ml.rcf.CombinedRcfResult; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; +import com.amazon.opendistroforelasticsearch.ad.model.FeatureData; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStat; +import com.amazon.opendistroforelasticsearch.ad.stats.ADStats; +import com.amazon.opendistroforelasticsearch.ad.stats.StatNames; +import com.amazon.opendistroforelasticsearch.ad.stats.suppliers.CounterSupplier; +import com.amazon.opendistroforelasticsearch.ad.util.ClientUtil; +import com.amazon.opendistroforelasticsearch.ad.util.ColdStartRunner; +import com.amazon.opendistroforelasticsearch.ad.util.IndexUtils; +import com.amazon.opendistroforelasticsearch.ad.util.Throttler; +import com.google.gson.JsonElement; + public class AnomalyResultTests extends AbstractADTest { private static Settings settings = Settings.EMPTY; private TransportService transportService; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportActionTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportActionTests.java index a1e556dc..38ce9fa6 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportActionTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/CronTransportActionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -23,11 +23,6 @@ import java.util.Collections; import java.util.function.Function; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; - import org.elasticsearch.Version; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.cluster.ClusterName; @@ -44,10 +39,14 @@ import org.junit.Assert; import org.junit.Before; -import com.google.gson.JsonElement; - import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.google.gson.JsonElement; + public class CronTransportActionTests extends AbstractADTest { private CronTransportAction action; private String localNodeID; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteIT.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteIT.java index bca169a4..855f2bf6 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteIT.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -19,13 +19,14 @@ import java.util.Collections; import java.util.concurrent.ExecutionException; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; + @ESIntegTestCase.ClusterScope(transportClientRatio = 0.9) public class DeleteIT extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportActionTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportActionTests.java index 7d60ffce..e5b1dd55 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportActionTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteModelTransportActionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -25,12 +25,6 @@ import java.util.Collections; import java.util.function.Function; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; - import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.ActionFilters; @@ -49,10 +43,15 @@ import org.junit.Assert; import org.junit.Before; -import com.google.gson.JsonElement; - import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.google.gson.JsonElement; + public class DeleteModelTransportActionTests extends AbstractADTest { private DeleteModelTransportAction action; private String localNodeID; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteTests.java index 9beb3c14..cd5336ac 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/DeleteTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; - import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -35,11 +34,6 @@ import java.util.List; import java.util.function.Supplier; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.cluster.DeleteDetector; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; @@ -71,6 +65,12 @@ import test.com.amazon.opendistroforelasticsearch.ad.util.ClusterCreation; import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.cluster.DeleteDetector; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; + public class DeleteTests extends AbstractADTest { private DeleteModelResponse response; private List failures; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileIT.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileIT.java index 2acd0542..9961eaf8 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileIT.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileIT.java @@ -15,17 +15,17 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; -import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; - -import org.elasticsearch.plugins.Plugin; -import org.elasticsearch.test.ESIntegTestCase; - import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.concurrent.ExecutionException; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.test.ESIntegTestCase; + +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; +import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; + @ESIntegTestCase.ClusterScope(transportClientRatio = 0.9) public class ProfileIT extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTests.java index 91c59c2e..c35324a8 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTests.java @@ -15,11 +15,18 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.model.ModelProfile; -import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; +import static java.util.Collections.emptyMap; +import static java.util.Collections.emptySet; +import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.elasticsearch.Version; import org.elasticsearch.action.FailedNodeException; @@ -34,20 +41,14 @@ import org.elasticsearch.test.ESTestCase; import org.junit.Before; import org.junit.Test; -import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; -import static java.util.Collections.emptyMap; -import static java.util.Collections.emptySet; -import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.model.ModelProfile; +import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; public class ProfileTests extends ESTestCase { String node1, nodeName1, clusterName; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportActionTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportActionTests.java index 58630bf7..03794698 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportActionTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ProfileTransportActionTests.java @@ -15,17 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.transport; -import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; - -import org.elasticsearch.action.FailedNodeException; -import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.transport.TransportService; -import org.junit.Before; -import org.junit.Test; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.Arrays; @@ -35,9 +27,17 @@ import java.util.Map; import java.util.Set; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import org.elasticsearch.action.FailedNodeException; +import org.elasticsearch.action.support.ActionFilters; +import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.transport.TransportService; +import org.junit.Before; +import org.junit.Test; + +import com.amazon.opendistroforelasticsearch.ad.feature.FeatureManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.model.ProfileName; public class ProfileTransportActionTests extends ESIntegTestCase { private ProfileTransportAction action; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultIT.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultIT.java index 5e3b62a6..8b972396 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultIT.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ import java.util.Collections; import java.util.concurrent.ExecutionException; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; + @ESIntegTestCase.ClusterScope(transportClientRatio = 0.9) public class RCFResultIT extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTests.java index 9084ee6a..a11ca716 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/RCFResultTests.java @@ -27,14 +27,6 @@ import java.io.IOException; import java.util.Collections; -import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.ml.RcfResult; - import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.ActionFilters; @@ -49,13 +41,20 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportService; +import org.hamcrest.Matchers; + +import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; +import com.amazon.opendistroforelasticsearch.ad.breaker.ADCircuitBreakerService; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.common.exception.LimitExceededException; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.ml.RcfResult; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import org.hamcrest.Matchers; -import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; - public class RCFResultTests extends ESTestCase { Gson gson = new GsonBuilder().create(); diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultIT.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultIT.java index 23f1ff66..b4f7142e 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultIT.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ import java.util.Collections; import java.util.concurrent.ExecutionException; -import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; +import com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorPlugin; + @ESIntegTestCase.ClusterScope(transportClientRatio = 0.9) public class ThresholdResultIT extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultTests.java index 4a992126..95500907 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/ThresholdResultTests.java @@ -26,12 +26,6 @@ import java.io.IOException; import java.util.Collections; -import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; -import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; -import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; -import com.amazon.opendistroforelasticsearch.ad.ml.ThresholdingResult; - import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.ActionFilters; @@ -46,10 +40,16 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportService; - import org.hamcrest.Matchers; + import test.com.amazon.opendistroforelasticsearch.ad.util.JsonDeserializer; +import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonErrorMessages; +import com.amazon.opendistroforelasticsearch.ad.constant.CommonMessageAttributes; +import com.amazon.opendistroforelasticsearch.ad.ml.ModelManager; +import com.amazon.opendistroforelasticsearch.ad.ml.ThresholdingResult; + public class ThresholdResultTests extends ESTestCase { @SuppressWarnings("unchecked") diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandlerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandlerTests.java index 91dd0243..d4d4b3b1 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandlerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/transport/handler/AnomalyResultHandlerTests.java @@ -15,12 +15,19 @@ package com.amazon.opendistroforelasticsearch.ad.transport.handler; -import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; -import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; -import com.amazon.opendistroforelasticsearch.ad.transport.AnomalyResultTests; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.createIndexBlockedState; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.Arrays; +import java.util.concurrent.CountDownLatch; + import org.elasticsearch.ResourceAlreadyExistsException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; @@ -44,18 +51,12 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.io.IOException; -import java.util.Arrays; -import java.util.concurrent.CountDownLatch; - -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.createIndexBlockedState; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import com.amazon.opendistroforelasticsearch.ad.AbstractADTest; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; +import com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyResult; +import com.amazon.opendistroforelasticsearch.ad.transport.AnomalyResultTests; public class AnomalyResultHandlerTests extends AbstractADTest { private static Settings settings; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ArrayEqMatcher.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ArrayEqMatcher.java index 0c251c65..c35080d4 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ArrayEqMatcher.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ArrayEqMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunnerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunnerTests.java index 059177a8..0dcb9c12 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunnerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ColdStartRunnerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -22,13 +22,14 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.test.ESTestCase; import org.junit.After; import org.junit.Before; +import com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException; + public class ColdStartRunnerTests extends ESTestCase { private static final Logger LOG = LogManager.getLogger(ColdStartRunnerTests.class); private ColdStartRunner runner; diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java index f26e66e3..fc250f3f 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/IndexUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,6 +15,10 @@ package com.amazon.opendistroforelasticsearch.ad.util; +import static org.mockito.Mockito.mock; + +import java.time.Clock; + import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.Settings; @@ -24,9 +28,6 @@ import org.junit.Test; import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import java.time.Clock; - -import static org.mockito.Mockito.mock; public class IndexUtilsTests extends ESIntegTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtilsTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtilsTests.java index 0ae6faa0..ed729237 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtilsTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ParseUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ package com.amazon.opendistroforelasticsearch.ad.util; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.amazon.opendistroforelasticsearch.ad.model.Feature; +import java.io.IOException; +import java.time.Instant; + import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; @@ -26,8 +26,9 @@ import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.test.ESTestCase; -import java.io.IOException; -import java.time.Instant; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.amazon.opendistroforelasticsearch.ad.model.Feature; public class ParseUtilsTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtilsTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtilsTests.java index 54e908d7..1406963b 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtilsTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/RestHandlerUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,10 +15,11 @@ package com.amazon.opendistroforelasticsearch.ad.util; -import com.amazon.opendistroforelasticsearch.ad.TestHelpers; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.builder; +import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomFeature; + +import java.io.IOException; + import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -30,10 +31,10 @@ import org.elasticsearch.test.rest.FakeRestChannel; import org.elasticsearch.test.rest.FakeRestRequest; -import java.io.IOException; - -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.builder; -import static com.amazon.opendistroforelasticsearch.ad.TestHelpers.randomFeature; +import com.amazon.opendistroforelasticsearch.ad.TestHelpers; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; public class RestHandlerUtilsTests extends ESTestCase { diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ThrottlerTests.java b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ThrottlerTests.java index df91946e..dfaa5fb9 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ThrottlerTests.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/ad/util/ThrottlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. @@ -15,15 +15,17 @@ package com.amazon.opendistroforelasticsearch.ad.util; -import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; +import static org.mockito.Mockito.mock; +import static org.powermock.api.mockito.PowerMockito.when; + +import java.time.Clock; + import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.test.ESTestCase; import org.junit.Before; import org.junit.Test; -import java.time.Clock; -import static org.mockito.Mockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; +import com.amazon.opendistroforelasticsearch.ad.model.AnomalyDetector; public class ThrottlerTests extends ESTestCase { private Throttler throttler; diff --git a/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/ClusterCreation.java b/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/ClusterCreation.java index a479d022..f99fe781 100644 --- a/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/ClusterCreation.java +++ b/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/ClusterCreation.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/FakeNode.java b/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/FakeNode.java index e0405cd8..7e0fe2b1 100644 --- a/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/FakeNode.java +++ b/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/FakeNode.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. diff --git a/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/JsonDeserializer.java b/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/JsonDeserializer.java index 2788f59a..e8c69025 100644 --- a/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/JsonDeserializer.java +++ b/src/test/java/test/com/amazon/opendistroforelasticsearch/ad/util/JsonDeserializer.java @@ -23,11 +23,11 @@ import org.apache.commons.lang.StringUtils; import com.amazon.opendistroforelasticsearch.ad.common.exception.JsonPathNotFoundException; -import com.google.gson.JsonParser; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; public class JsonDeserializer { private static JsonParser parser = new JsonParser();