From f9de2fdc7478f9431f33759aae361247ae2f905e Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Fri, 18 Nov 2016 16:57:00 +0000 Subject: [PATCH] Remove unused headers and variables Original commit: elastic/x-pack-elasticsearch@c720e2f8cc1cbd3d18b773d056eb45c827ad9303 --- .../xpack/prelert/PrelertPlugin.java | 32 +++++++++---------- .../xpack/prelert/job/manager/JobManager.java | 6 ---- .../persistence/ElasticsearchPersister.java | 1 - .../BlackHoleAutodetectProcess.java | 3 -- .../prelert/job/status/StatusReporter.java | 1 - .../prelert/utils/CloseableIterator.java | 2 -- .../action/GetBucketActionResponseTests.java | 1 - .../GetCategoryDefinitionResponseTests.java | 1 - .../action/GetJobActionResponseTests.java | 1 - .../action/GetRecordsActionResponseTests.java | 1 - .../xpack/prelert/action/ScheduledJobsIT.java | 11 +++---- .../AutodetectCommunicatorTests.java | 1 - 12 files changed, 20 insertions(+), 41 deletions(-) diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java index 0d477f1b3cc..1589623bc22 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/PrelertPlugin.java @@ -27,7 +27,6 @@ import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.watcher.ResourceWatcherService; -import org.elasticsearch.xpack.prelert.action.PutListAction; import org.elasticsearch.xpack.prelert.action.DeleteJobAction; import org.elasticsearch.xpack.prelert.action.DeleteModelSnapshotAction; import org.elasticsearch.xpack.prelert.action.GetBucketAction; @@ -43,6 +42,7 @@ import org.elasticsearch.xpack.prelert.action.PostDataAction; import org.elasticsearch.xpack.prelert.action.PostDataCloseAction; import org.elasticsearch.xpack.prelert.action.PostDataFlushAction; import org.elasticsearch.xpack.prelert.action.PutJobAction; +import org.elasticsearch.xpack.prelert.action.PutListAction; import org.elasticsearch.xpack.prelert.action.PutModelSnapshotDescriptionAction; import org.elasticsearch.xpack.prelert.action.ResumeJobAction; import org.elasticsearch.xpack.prelert.action.RevertModelSnapshotAction; @@ -57,20 +57,18 @@ import org.elasticsearch.xpack.prelert.job.data.DataProcessor; import org.elasticsearch.xpack.prelert.job.logs.JobLogs; import org.elasticsearch.xpack.prelert.job.manager.AutodetectProcessManager; import org.elasticsearch.xpack.prelert.job.manager.JobManager; -import org.elasticsearch.xpack.prelert.job.persistence.ElasticsearchBulkDeleterFactory; -import org.elasticsearch.xpack.prelert.job.persistence.ElasticsearchJobProvider; -import org.elasticsearch.xpack.prelert.job.process.autodetect.output.parsing.AutoDetectResultProcessor; -import org.elasticsearch.xpack.prelert.job.process.autodetect.output.parsing.AutodetectResultsParser; -import org.elasticsearch.xpack.prelert.job.process.normalizer.noop.NoOpRenormaliser; -import org.elasticsearch.xpack.prelert.job.scheduler.ScheduledJobService; import org.elasticsearch.xpack.prelert.job.metadata.JobAllocator; import org.elasticsearch.xpack.prelert.job.metadata.JobLifeCycleService; import org.elasticsearch.xpack.prelert.job.metadata.PrelertMetadata; +import org.elasticsearch.xpack.prelert.job.persistence.ElasticsearchBulkDeleterFactory; +import org.elasticsearch.xpack.prelert.job.persistence.ElasticsearchJobProvider; import org.elasticsearch.xpack.prelert.job.process.NativeController; import org.elasticsearch.xpack.prelert.job.process.ProcessCtrl; import org.elasticsearch.xpack.prelert.job.process.autodetect.AutodetectProcessFactory; import org.elasticsearch.xpack.prelert.job.process.autodetect.BlackHoleAutodetectProcess; import org.elasticsearch.xpack.prelert.job.process.autodetect.NativeAutodetectProcessFactory; +import org.elasticsearch.xpack.prelert.job.process.autodetect.output.parsing.AutodetectResultsParser; +import org.elasticsearch.xpack.prelert.job.scheduler.ScheduledJobService; import org.elasticsearch.xpack.prelert.job.scheduler.http.HttpDataExtractorFactory; import org.elasticsearch.xpack.prelert.job.status.StatusReporter; import org.elasticsearch.xpack.prelert.job.usage.UsageReporter; @@ -84,8 +82,8 @@ import org.elasticsearch.xpack.prelert.rest.job.RestGetJobsAction; import org.elasticsearch.xpack.prelert.rest.job.RestPauseJobAction; import org.elasticsearch.xpack.prelert.rest.job.RestPutJobsAction; import org.elasticsearch.xpack.prelert.rest.job.RestResumeJobAction; -import org.elasticsearch.xpack.prelert.rest.list.RestPutListAction; import org.elasticsearch.xpack.prelert.rest.list.RestGetListAction; +import org.elasticsearch.xpack.prelert.rest.list.RestPutListAction; import org.elasticsearch.xpack.prelert.rest.modelsnapshots.RestDeleteModelSnapshotAction; import org.elasticsearch.xpack.prelert.rest.modelsnapshots.RestGetModelSnapshotsAction; import org.elasticsearch.xpack.prelert.rest.modelsnapshots.RestPutModelSnapshotDescriptionAction; @@ -176,13 +174,13 @@ public class PrelertPlugin extends Plugin implements ActionPlugin { ScheduledJobService scheduledJobService = new ScheduledJobService(threadPool, client, jobProvider, dataProcessor, new HttpDataExtractorFactory(), System::currentTimeMillis); return Arrays.asList( - jobProvider, - jobManager, - new JobAllocator(settings, clusterService, threadPool), - new JobLifeCycleService(settings, client, clusterService, scheduledJobService, dataProcessor, threadPool.generic()), - new ElasticsearchBulkDeleterFactory(client), //NORELEASE: this should use Delete-by-query - dataProcessor - ); + jobProvider, + jobManager, + new JobAllocator(settings, clusterService, threadPool), + new JobLifeCycleService(settings, client, clusterService, scheduledJobService, dataProcessor, threadPool.generic()), + new ElasticsearchBulkDeleterFactory(client), //NORELEASE: this should use Delete-by-query + dataProcessor + ); } @Override @@ -212,7 +210,7 @@ public class PrelertPlugin extends Plugin implements ActionPlugin { RestStartJobSchedulerAction.class, RestStopJobSchedulerAction.class, RestDeleteModelSnapshotAction.class - ); + ); } @Override @@ -244,7 +242,7 @@ public class PrelertPlugin extends Plugin implements ActionPlugin { new ActionHandler<>(StartJobSchedulerAction.INSTANCE, StartJobSchedulerAction.TransportAction.class), new ActionHandler<>(StopJobSchedulerAction.INSTANCE, StopJobSchedulerAction.TransportAction.class), new ActionHandler<>(DeleteModelSnapshotAction.INSTANCE, DeleteModelSnapshotAction.TransportAction.class) - ); + ); } public static Path resolveConfigFile(Environment env, String name) { diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/manager/JobManager.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/manager/JobManager.java index 616d2cf6a25..eba9aa94754 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/manager/JobManager.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/manager/JobManager.java @@ -13,12 +13,9 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateUpdateTask; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; -import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.component.Lifecycle; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; -import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.xpack.prelert.action.DeleteJobAction; import org.elasticsearch.xpack.prelert.action.PauseJobAction; import org.elasticsearch.xpack.prelert.action.PutJobAction; @@ -43,14 +40,11 @@ import org.elasticsearch.xpack.prelert.job.persistence.QueryPage; import org.elasticsearch.xpack.prelert.job.results.AnomalyRecord; import org.elasticsearch.xpack.prelert.utils.ExceptionsHelper; -import java.io.IOException; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.function.Function; import java.util.stream.Collectors; /** diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchPersister.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchPersister.java index 25a91ad28b2..021a8ca273a 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchPersister.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/persistence/ElasticsearchPersister.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.prelert.job.persistence; import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; import org.elasticsearch.action.bulk.BulkRequestBuilder; import org.elasticsearch.action.bulk.BulkResponse; diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/BlackHoleAutodetectProcess.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/BlackHoleAutodetectProcess.java index a558b183019..eb2c9ca3d9b 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/BlackHoleAutodetectProcess.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/process/autodetect/BlackHoleAutodetectProcess.java @@ -7,10 +7,7 @@ package org.elasticsearch.xpack.prelert.job.process.autodetect; import org.apache.logging.log4j.Logger; import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContent; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.xpack.prelert.job.process.autodetect.output.FlushAcknowledgement; import org.elasticsearch.xpack.prelert.job.process.autodetect.params.DataLoadParams; diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/status/StatusReporter.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/status/StatusReporter.java index b539cdbe92a..7f4bc1002a2 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/status/StatusReporter.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/job/status/StatusReporter.java @@ -16,7 +16,6 @@ import org.elasticsearch.xpack.prelert.job.usage.UsageReporter; import java.util.Date; import java.util.Locale; -import java.util.concurrent.atomic.AtomicLong; /** diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/utils/CloseableIterator.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/utils/CloseableIterator.java index 5072ff9d85f..82b29473edc 100644 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/utils/CloseableIterator.java +++ b/elasticsearch/src/main/java/org/elasticsearch/xpack/prelert/utils/CloseableIterator.java @@ -6,9 +6,7 @@ package org.elasticsearch.xpack.prelert.utils; import java.io.Closeable; -import java.io.IOException; import java.util.Iterator; -import java.util.NoSuchElementException; /** * An interface for iterators that can have resources that will be automatically cleaned up diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetBucketActionResponseTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetBucketActionResponseTests.java index 489dd5f6e2b..a07d484a6ef 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetBucketActionResponseTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetBucketActionResponseTests.java @@ -13,7 +13,6 @@ import org.elasticsearch.xpack.prelert.job.results.BucketInfluencer; import org.elasticsearch.xpack.prelert.job.results.Influencer; import org.elasticsearch.xpack.prelert.job.results.PartitionScore; import org.elasticsearch.xpack.prelert.support.AbstractStreamableTestCase; -import org.elasticsearch.xpack.prelert.utils.SingleDocument; import java.util.ArrayList; import java.util.Collections; diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetCategoryDefinitionResponseTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetCategoryDefinitionResponseTests.java index eac364684a2..612574a54fd 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetCategoryDefinitionResponseTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetCategoryDefinitionResponseTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.prelert.action; import org.elasticsearch.xpack.prelert.job.persistence.QueryPage; import org.elasticsearch.xpack.prelert.job.results.CategoryDefinition; import org.elasticsearch.xpack.prelert.support.AbstractStreamableTestCase; -import org.elasticsearch.xpack.prelert.utils.SingleDocument; import java.util.Collections; diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetJobActionResponseTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetJobActionResponseTests.java index 7a3fdba9945..819259507dc 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetJobActionResponseTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetJobActionResponseTests.java @@ -19,7 +19,6 @@ import org.elasticsearch.xpack.prelert.job.SchedulerConfig; import org.elasticsearch.xpack.prelert.job.transform.TransformConfig; import org.elasticsearch.xpack.prelert.job.transform.TransformType; import org.elasticsearch.xpack.prelert.support.AbstractStreamableTestCase; -import org.elasticsearch.xpack.prelert.utils.SingleDocument; import org.joda.time.DateTime; import java.util.ArrayList; diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetRecordsActionResponseTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetRecordsActionResponseTests.java index 155bc7a4aaf..e2a5afde8d8 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetRecordsActionResponseTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/GetRecordsActionResponseTests.java @@ -20,7 +20,6 @@ public class GetRecordsActionResponseTests extends AbstractStreamableTestCase hits = new ArrayList<>(listSize); String jobId = randomAsciiOfLengthBetween(1, 20); - String bucketId = randomAsciiOfLengthBetween(1, 20); for (int j = 0; j < listSize; j++) { AnomalyRecord record = new AnomalyRecord(jobId); record.setId(randomAsciiOfLengthBetween(1, 20)); diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/ScheduledJobsIT.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/ScheduledJobsIT.java index ce59089ce4d..bcb3909c90c 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/ScheduledJobsIT.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/action/ScheduledJobsIT.java @@ -10,7 +10,6 @@ import org.elasticsearch.action.bulk.BulkResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.WriteRequest; -import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.ParseFieldMatcher; import org.elasticsearch.common.network.NetworkAddress; @@ -82,8 +81,8 @@ public class ScheduledJobsIT extends ESIntegTestCase { public void testLookbackOnly() throws Exception { client().admin().indices().prepareCreate("data") - .addMapping("type", "time", "type=date") - .get(); + .addMapping("type", "time", "type=date") + .get(); long numDocs = randomIntBetween(32, 2048); long now = System.currentTimeMillis(); long lastWeek = now - 604800000; @@ -112,8 +111,8 @@ public class ScheduledJobsIT extends ESIntegTestCase { public void testRealtime() throws Exception { client().admin().indices().prepareCreate("data") - .addMapping("type", "time", "type=date") - .get(); + .addMapping("type", "time", "type=date") + .get(); long numDocs1 = randomIntBetween(32, 2048); long now = System.currentTimeMillis(); long lastWeek = System.currentTimeMillis() - 604800000; @@ -143,7 +142,7 @@ public class ScheduledJobsIT extends ESIntegTestCase { }, 30, TimeUnit.SECONDS); StopJobSchedulerAction.Request stopSchedulerRequest = new StopJobSchedulerAction.Request("_job_id"); - StopJobSchedulerAction.Response stopJobResponse = client().execute(StopJobSchedulerAction.INSTANCE, stopSchedulerRequest).get(); + client().execute(StopJobSchedulerAction.INSTANCE, stopSchedulerRequest).get(); assertTrue(startJobResponse.isAcknowledged()); assertBusy(() -> { PrelertMetadata prelertMetadata = client().admin().cluster().prepareState().all().get() diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/process/autodetect/AutodetectCommunicatorTests.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/process/autodetect/AutodetectCommunicatorTests.java index 38888e2e6ff..e2cef77c690 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/process/autodetect/AutodetectCommunicatorTests.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/process/autodetect/AutodetectCommunicatorTests.java @@ -69,7 +69,6 @@ public class AutodetectCommunicatorTests extends ESTestCase { AutodetectProcess process = mockAutodetectProcessWithOutputStream(); when(process.isProcessAlive()).thenReturn(false); when(process.readError()).thenReturn("Mock process is dead"); - @SuppressWarnings("resource") AutodetectCommunicator communicator = createAutodetectCommunicator(process, mock(AutoDetectResultProcessor.class)); InterimResultsParams params = InterimResultsParams.builder().build(); ElasticsearchException e = ESTestCase.expectThrows(ElasticsearchException.class, () -> communicator.flushJob(params));