Răsfoiți Sursa

Remove some Dead Code from Discovery Plugins (#50592)

None of this stuff is used.
Armin Braun 5 ani în urmă
părinte
comite
77fd51f30b
18 a modificat fișierele cu 17 adăugiri și 81 ștergeri
  1. 0 3
      plugins/discovery-azure-classic/src/main/java/org/elasticsearch/cloud/azure/classic/AzureServiceDisableException.java
  2. 0 3
      plugins/discovery-azure-classic/src/main/java/org/elasticsearch/cloud/azure/classic/AzureServiceRemoteException.java
  3. 2 2
      plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2ServiceImpl.java
  4. 2 2
      plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/AwsEc2ServiceImplTests.java
  5. 0 47
      plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceModule.java
  6. 1 1
      server/src/main/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandler.java
  7. 1 2
      server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java
  8. 0 5
      server/src/main/java/org/elasticsearch/discovery/MasterNotDiscoveredException.java
  9. 1 1
      server/src/main/java/org/elasticsearch/gateway/LocalAllocateDangledIndices.java
  10. 1 1
      server/src/main/java/org/elasticsearch/node/Node.java
  11. 1 1
      server/src/test/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandlerTests.java
  12. 2 7
      server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java
  13. 1 1
      x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportCloseJobAction.java
  14. 1 1
      x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDataFrameAnalyticsAction.java
  15. 1 1
      x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDatafeedAction.java
  16. 1 1
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportDeleteRollupJobAction.java
  17. 1 1
      x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupJobAction.java
  18. 1 1
      x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java

+ 0 - 3
plugins/discovery-azure-classic/src/main/java/org/elasticsearch/cloud/azure/classic/AzureServiceDisableException.java

@@ -20,9 +20,6 @@
 package org.elasticsearch.cloud.azure.classic;
 
 public class AzureServiceDisableException extends IllegalStateException {
-    public AzureServiceDisableException(String msg) {
-        super(msg);
-    }
 
     public AzureServiceDisableException(String msg, Throwable cause) {
         super(msg, cause);

+ 0 - 3
plugins/discovery-azure-classic/src/main/java/org/elasticsearch/cloud/azure/classic/AzureServiceRemoteException.java

@@ -20,9 +20,6 @@
 package org.elasticsearch.cloud.azure.classic;
 
 public class AzureServiceRemoteException extends IllegalStateException {
-    public AzureServiceRemoteException(String msg) {
-        super(msg);
-    }
 
     public AzureServiceRemoteException(String msg, Throwable cause) {
         super(msg, cause);

+ 2 - 2
plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2ServiceImpl.java

@@ -44,7 +44,7 @@ class AwsEc2ServiceImpl implements AwsEc2Service {
 
     private AmazonEC2 buildClient(Ec2ClientSettings clientSettings) {
         final AWSCredentialsProvider credentials = buildCredentials(logger, clientSettings);
-        final ClientConfiguration configuration = buildConfiguration(logger, clientSettings);
+        final ClientConfiguration configuration = buildConfiguration(clientSettings);
         final AmazonEC2 client = buildClient(credentials, configuration);
         if (Strings.hasText(clientSettings.endpoint)) {
             logger.debug("using explicit ec2 endpoint [{}]", clientSettings.endpoint);
@@ -60,7 +60,7 @@ class AwsEc2ServiceImpl implements AwsEc2Service {
     }
 
     // pkg private for tests
-    static ClientConfiguration buildConfiguration(Logger logger, Ec2ClientSettings clientSettings) {
+    static ClientConfiguration buildConfiguration(Ec2ClientSettings clientSettings) {
         final ClientConfiguration clientConfiguration = new ClientConfiguration();
         // the response metadata cache is only there for diagnostics purposes,
         // but can force objects from every response to the old generation.

+ 2 - 2
plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/AwsEc2ServiceImplTests.java

@@ -120,8 +120,8 @@ public class AwsEc2ServiceImplTests extends ESTestCase {
                                               String expectedProxyUsername,
                                               String expectedProxyPassword,
                                               int expectedReadTimeout) {
-        final ClientConfiguration configuration = AwsEc2ServiceImpl.buildConfiguration(logger,
-                Ec2ClientSettings.getClientSettings(settings));
+        final ClientConfiguration configuration = AwsEc2ServiceImpl.buildConfiguration(
+            Ec2ClientSettings.getClientSettings(settings));
 
         assertThat(configuration.getResponseMetadataCacheSize(), is(0));
         assertThat(configuration.getProtocol(), is(expectedProtocol));

+ 0 - 47
plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceModule.java

@@ -1,47 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License 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 org.elasticsearch.cloud.gce;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.elasticsearch.common.inject.AbstractModule;
-import org.elasticsearch.common.settings.Settings;
-
-public class GceModule extends AbstractModule {
-    // pkg private so tests can override with mock
-    static Class<? extends GceInstancesService> computeServiceImpl = GceInstancesServiceImpl.class;
-
-    protected final Settings settings;
-    protected final Logger logger = LogManager.getLogger(GceModule.class);
-
-    public GceModule(Settings settings) {
-        this.settings = settings;
-    }
-
-    public static Class<? extends GceInstancesService> getComputeServiceImpl() {
-        return computeServiceImpl;
-    }
-
-    @Override
-    protected void configure() {
-        logger.debug("configure GceModule (bind compute service)");
-        bind(GceInstancesService.class).to(computeServiceImpl).asEagerSingleton();
-    }
-}

+ 1 - 1
server/src/main/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandler.java

@@ -64,7 +64,7 @@ public class BlockingClusterStatePublishResponseHandler {
      * Called for each failure obtained from non master nodes
      * @param node the node that replied to the publish event
      */
-    public void onFailure(DiscoveryNode node, Exception e) {
+    public void onFailure(DiscoveryNode node) {
         boolean found = pendingNodes.remove(node);
         assert found : "node [" + node + "] already responded or failed";
         boolean added = failedNodes.add(node);

+ 1 - 2
server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java

@@ -39,7 +39,6 @@ import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.transport.TransportAddress;
 import org.elasticsearch.gateway.GatewayMetaState;
 import org.elasticsearch.plugins.DiscoveryPlugin;
-import org.elasticsearch.threadpool.ThreadPool;
 import org.elasticsearch.transport.TransportService;
 
 import java.nio.file.Path;
@@ -82,7 +81,7 @@ public class DiscoveryModule {
 
     private final Discovery discovery;
 
-    public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportService transportService,
+    public DiscoveryModule(Settings settings, TransportService transportService,
                            NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService, MasterService masterService,
                            ClusterApplier clusterApplier, ClusterSettings clusterSettings, List<DiscoveryPlugin> plugins,
                            AllocationService allocationService, Path configFile, GatewayMetaState gatewayMetaState,

+ 0 - 5
server/src/main/java/org/elasticsearch/discovery/MasterNotDiscoveredException.java

@@ -30,15 +30,10 @@ public class MasterNotDiscoveredException extends ElasticsearchException {
     public MasterNotDiscoveredException() {
         super("");
     }
-
     public MasterNotDiscoveredException(Throwable cause) {
         super(cause);
     }
 
-    public MasterNotDiscoveredException(String message) {
-        super(message);
-    }
-
     @Override
     public RestStatus status() {
         return RestStatus.SERVICE_UNAVAILABLE;

+ 1 - 1
server/src/main/java/org/elasticsearch/gateway/LocalAllocateDangledIndices.java

@@ -80,7 +80,7 @@ public class LocalAllocateDangledIndices {
         ClusterState clusterState = clusterService.state();
         DiscoveryNode masterNode = clusterState.nodes().getMasterNode();
         if (masterNode == null) {
-            listener.onFailure(new MasterNotDiscoveredException("no master to send allocate dangled request"));
+            listener.onFailure(new MasterNotDiscoveredException());
             return;
         }
         AllocateDangledRequest request = new AllocateDangledRequest(clusterService.localNode(),

+ 1 - 1
server/src/main/java/org/elasticsearch/node/Node.java

@@ -496,7 +496,7 @@ public class Node implements Closeable {
                 clusterService.getClusterSettings(), client, threadPool::relativeTimeInMillis, rerouteService);
             clusterInfoService.addListener(diskThresholdMonitor::onNewInfo);
 
-            final DiscoveryModule discoveryModule = new DiscoveryModule(settings, threadPool, transportService, namedWriteableRegistry,
+            final DiscoveryModule discoveryModule = new DiscoveryModule(settings, transportService, namedWriteableRegistry,
                 networkService, clusterService.getMasterService(), clusterService.getClusterApplierService(),
                 clusterService.getClusterSettings(), pluginsService.filterPlugins(DiscoveryPlugin.class),
                 clusterModule.getAllocationService(), environment.configFile(), gatewayMetaState, rerouteService);

+ 1 - 1
server/src/test/java/org/elasticsearch/discovery/BlockingClusterStatePublishResponseHandlerTests.java

@@ -66,7 +66,7 @@ public class BlockingClusterStatePublishResponseHandlerTests extends ESTestCase
         protected void doRun() throws Exception {
             barrier.await();
             if (fail) {
-                handler.onFailure(node, new Exception("bla"));
+                handler.onFailure(node);
             } else {
                 handler.onResponse(node);
             }

+ 2 - 7
server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java

@@ -29,7 +29,6 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
 import org.elasticsearch.common.network.NetworkService;
 import org.elasticsearch.common.settings.ClusterSettings;
 import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.util.concurrent.ThreadContext;
 import org.elasticsearch.core.internal.io.IOUtils;
 import org.elasticsearch.gateway.GatewayMetaState;
 import org.elasticsearch.plugins.DiscoveryPlugin;
@@ -51,7 +50,6 @@ import java.util.function.BiConsumer;
 import java.util.function.Supplier;
 
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class DiscoveryModuleTests extends ESTestCase {
 
@@ -59,7 +57,6 @@ public class DiscoveryModuleTests extends ESTestCase {
     private NamedWriteableRegistry namedWriteableRegistry;
     private MasterService masterService;
     private ClusterApplier clusterApplier;
-    private ThreadPool threadPool;
     private ClusterSettings clusterSettings;
     private GatewayMetaState gatewayMetaState;
 
@@ -74,9 +71,7 @@ public class DiscoveryModuleTests extends ESTestCase {
 
     @Before
     public void setupDummyServices() {
-        threadPool = mock(ThreadPool.class);
-        when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY));
-        transportService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, threadPool, null);
+        transportService = MockTransportService.createNewService(Settings.EMPTY, Version.CURRENT, mock(ThreadPool.class), null);
         masterService = mock(MasterService.class);
         namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
         clusterApplier = mock(ClusterApplier.class);
@@ -90,7 +85,7 @@ public class DiscoveryModuleTests extends ESTestCase {
     }
 
     private DiscoveryModule newModule(Settings settings, List<DiscoveryPlugin> plugins) {
-        return new DiscoveryModule(settings, threadPool, transportService, namedWriteableRegistry, null, masterService,
+        return new DiscoveryModule(settings, transportService, namedWriteableRegistry, null, masterService,
             clusterApplier, clusterSettings, plugins, null, createTempDir().toAbsolutePath(), gatewayMetaState,
             mock(RerouteService.class));
     }

+ 1 - 1
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportCloseJobAction.java

@@ -87,7 +87,7 @@ public class TransportCloseJobAction extends TransportTasksAction<TransportOpenJ
             // Delegates close job to elected master node, so it becomes the coordinating node.
             // See comment in OpenJobAction.Transport class for more information.
             if (nodes.getMasterNode() == null) {
-                listener.onFailure(new MasterNotDiscoveredException("no known master node"));
+                listener.onFailure(new MasterNotDiscoveredException());
             } else {
                 transportService.sendRequest(nodes.getMasterNode(), actionName, request,
                         new ActionListenerResponseHandler<>(listener, CloseJobAction.Response::new));

+ 1 - 1
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDataFrameAnalyticsAction.java

@@ -202,7 +202,7 @@ public class TransportStopDataFrameAnalyticsAction
     private void redirectToMasterNode(DiscoveryNode masterNode, StopDataFrameAnalyticsAction.Request request,
                                       ActionListener<StopDataFrameAnalyticsAction.Response> listener) {
         if (masterNode == null) {
-            listener.onFailure(new MasterNotDiscoveredException("no known master node"));
+            listener.onFailure(new MasterNotDiscoveredException());
         } else {
             transportService.sendRequest(masterNode, actionName, request,
                 new ActionListenerResponseHandler<>(listener, StopDataFrameAnalyticsAction.Response::new));

+ 1 - 1
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStopDatafeedAction.java

@@ -125,7 +125,7 @@ public class TransportStopDatafeedAction extends TransportTasksAction<TransportS
             // Delegates stop datafeed to elected master node, so it becomes the coordinating node.
             // See comment in TransportStartDatafeedAction for more information.
             if (nodes.getMasterNode() == null) {
-                listener.onFailure(new MasterNotDiscoveredException("no known master node"));
+                listener.onFailure(new MasterNotDiscoveredException());
             } else {
                 transportService.sendRequest(nodes.getMasterNode(), actionName, request,
                         new ActionListenerResponseHandler<>(listener, StopDatafeedAction.Response::new));

+ 1 - 1
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportDeleteRollupJobAction.java

@@ -57,7 +57,7 @@ public class TransportDeleteRollupJobAction extends TransportTasksAction<RollupJ
             // Non-master nodes may have a stale cluster state that shows jobs which are cancelled
             // on the master, which makes testing difficult.
             if (nodes.getMasterNode() == null) {
-                listener.onFailure(new MasterNotDiscoveredException("no known master nodes"));
+                listener.onFailure(new MasterNotDiscoveredException());
             } else {
                 transportService.sendRequest(nodes.getMasterNode(), actionName, request,
                     new ActionListenerResponseHandler<>(listener, DeleteRollupJobAction.Response::new));

+ 1 - 1
x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportGetRollupJobAction.java

@@ -59,7 +59,7 @@ public class TransportGetRollupJobAction extends TransportTasksAction<RollupJobT
             // Non-master nodes may have a stale cluster state that shows jobs which are cancelled
             // on the master, which makes testing difficult.
             if (nodes.getMasterNode() == null) {
-                listener.onFailure(new MasterNotDiscoveredException("no known master nodes"));
+                listener.onFailure(new MasterNotDiscoveredException());
             } else {
                 transportService.sendRequest(nodes.getMasterNode(), actionName, request,
                         new ActionListenerResponseHandler<>(listener, GetRollupJobsAction.Response::new));

+ 1 - 1
x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java

@@ -134,7 +134,7 @@ public class TransportStopTransformAction extends TransportTasksAction<Transform
         if (nodes.isLocalNodeElectedMaster() == false) {
             // Delegates stop transform to elected master node so it becomes the coordinating node.
             if (nodes.getMasterNode() == null) {
-                listener.onFailure(new MasterNotDiscoveredException("no known master node"));
+                listener.onFailure(new MasterNotDiscoveredException());
             } else {
                 transportService.sendRequest(
                     nodes.getMasterNode(),