Browse Source

Remove Dead Code in Transport Package (#39885)

* None of this stuff is used
Armin Braun 6 years ago
parent
commit
8e3dabcac4

+ 1 - 8
modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4TcpServerChannel.java

@@ -29,20 +29,13 @@ import java.net.InetSocketAddress;
 public class Netty4TcpServerChannel implements TcpServerChannel {
 
     private final Channel channel;
-    private final String profile;
     private final CompletableContext<Void> closeContext = new CompletableContext<>();
 
-    Netty4TcpServerChannel(Channel channel, String profile) {
+    Netty4TcpServerChannel(Channel channel) {
         this.channel = channel;
-        this.profile = profile;
         Netty4TcpChannel.addListener(this.channel.closeFuture(), closeContext);
     }
 
-    @Override
-    public String getProfile() {
-        return profile;
-    }
-
     @Override
     public InetSocketAddress getLocalAddress() {
         return (InetSocketAddress) channel.localAddress();

+ 1 - 1
modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java

@@ -243,7 +243,7 @@ public class Netty4Transport extends TcpTransport {
     @Override
     protected Netty4TcpServerChannel bind(String name, InetSocketAddress address) {
         Channel channel = serverBootstraps.get(name).bind(address).syncUninterruptibly().channel();
-        Netty4TcpServerChannel esChannel = new Netty4TcpServerChannel(channel, name);
+        Netty4TcpServerChannel esChannel = new Netty4TcpServerChannel(channel);
         channel.attr(SERVER_CHANNEL_KEY).set(esChannel);
         return esChannel;
     }

+ 1 - 9
plugins/transport-nio/src/main/java/org/elasticsearch/transport/nio/NioTcpServerChannel.java

@@ -31,22 +31,14 @@ import java.nio.channels.ServerSocketChannel;
  */
 public class NioTcpServerChannel extends NioServerSocketChannel implements TcpServerChannel {
 
-    private final String profile;
-
-    public NioTcpServerChannel(String profile, ServerSocketChannel socketChannel) {
+    public NioTcpServerChannel(ServerSocketChannel socketChannel) {
         super(socketChannel);
-        this.profile = profile;
     }
 
     public void close() {
         getContext().closeChannel();
     }
 
-    @Override
-    public String getProfile() {
-        return profile;
-    }
-
     @Override
     public void addCloseListener(ActionListener<Void> listener) {
         addCloseListener(ActionListener.toBiConsumer(listener));

+ 1 - 1
plugins/transport-nio/src/main/java/org/elasticsearch/transport/nio/NioTransport.java

@@ -171,7 +171,7 @@ public class NioTransport extends TcpTransport {
 
         @Override
         public NioTcpServerChannel createServerChannel(NioSelector selector, ServerSocketChannel channel) {
-            NioTcpServerChannel nioChannel = new NioTcpServerChannel(profileName, channel);
+            NioTcpServerChannel nioChannel = new NioTcpServerChannel(channel);
             Consumer<Exception> exceptionHandler = (e) -> onServerException(nioChannel, e);
             Consumer<NioSocketChannel> acceptor = NioTransport.this::acceptChannel;
             ServerChannelContext context = new ServerChannelContext(nioChannel, this, selector, acceptor, exceptionHandler);

+ 0 - 34
server/src/main/java/org/elasticsearch/threadpool/ThreadPool.java

@@ -448,40 +448,6 @@ public class ThreadPool implements Scheduler, Closeable {
         return ((availableProcessors * 3) / 2) + 1;
     }
 
-    class LoggingRunnable implements Runnable {
-
-        private final Runnable runnable;
-
-        LoggingRunnable(Runnable runnable) {
-            this.runnable = runnable;
-        }
-
-        @Override
-        public void run() {
-            try {
-                runnable.run();
-            } catch (Exception e) {
-                logger.warn(() -> new ParameterizedMessage("failed to run {}", runnable.toString()), e);
-                throw e;
-            }
-        }
-
-        @Override
-        public int hashCode() {
-            return runnable.hashCode();
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            return runnable.equals(obj);
-        }
-
-        @Override
-        public String toString() {
-            return "[threaded] " + runnable.toString();
-        }
-    }
-
     class ThreadedRunnable implements Runnable {
 
         private final Runnable runnable;

+ 0 - 5
server/src/main/java/org/elasticsearch/transport/NodeShouldNotConnectException.java

@@ -19,17 +19,12 @@
 
 package org.elasticsearch.transport;
 
-import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.common.io.stream.StreamInput;
 
 import java.io.IOException;
 
 public class NodeShouldNotConnectException extends NodeNotConnectedException {
 
-    public NodeShouldNotConnectException(DiscoveryNode fromNode, DiscoveryNode node) {
-        super(node, "node should not connect from [" + fromNode + "]");
-    }
-
     public NodeShouldNotConnectException(StreamInput in) throws IOException {
         super(in);
     }

+ 0 - 13
server/src/main/java/org/elasticsearch/transport/NotSerializableTransportException.java

@@ -25,10 +25,6 @@ import java.io.IOException;
 
 public class NotSerializableTransportException extends TransportException {
 
-    public NotSerializableTransportException(Throwable t) {
-        super(buildMessage(t));
-    }
-
     public NotSerializableTransportException(StreamInput in) throws IOException {
         super(in);
     }
@@ -38,13 +34,4 @@ public class NotSerializableTransportException extends TransportException {
         return null;
     }
 
-    private static String buildMessage(Throwable t) {
-        StringBuilder sb = new StringBuilder();
-        sb.append("[").append(t.getClass().getName()).append("] ");
-        while (t != null) {
-            sb.append(t.getMessage()).append("; ");
-            t = t.getCause();
-        }
-        return sb.toString();
-    }
 }

+ 0 - 20
server/src/main/java/org/elasticsearch/transport/PlainTransportFuture.java

@@ -20,14 +20,11 @@
 package org.elasticsearch.transport;
 
 import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.ElasticsearchTimeoutException;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.util.concurrent.BaseFuture;
 
 import java.io.IOException;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 public class PlainTransportFuture<V extends TransportResponse> extends BaseFuture<V>
     implements TransportFuture<V>, TransportResponseHandler<V> {
@@ -54,23 +51,6 @@ public class PlainTransportFuture<V extends TransportResponse> extends BaseFutur
         }
     }
 
-    @Override
-    public V txGet(long timeout, TimeUnit unit) {
-        try {
-            return get(timeout, unit);
-        } catch (TimeoutException e) {
-            throw new ElasticsearchTimeoutException(e);
-        } catch (InterruptedException e) {
-            throw new IllegalStateException("Future got interrupted", e);
-        } catch (ExecutionException e) {
-            if (e.getCause() instanceof ElasticsearchException) {
-                throw (ElasticsearchException) e.getCause();
-            } else {
-                throw new TransportException("Failed execution", e);
-            }
-        }
-    }
-
     @Override
     public V read(StreamInput in) throws IOException {
         return handler.read(in);

+ 0 - 5
server/src/main/java/org/elasticsearch/transport/TcpServerChannel.java

@@ -31,11 +31,6 @@ import java.net.InetSocketAddress;
  */
 public interface TcpServerChannel extends CloseableChannel {
 
-    /**
-     * This returns the profile for this channel.
-     */
-    String getProfile();
-
     /**
      * Returns the local address for this channel.
      *

+ 0 - 7
server/src/main/java/org/elasticsearch/transport/TransportFuture.java

@@ -20,7 +20,6 @@
 package org.elasticsearch.transport;
 
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 
 public interface TransportFuture<V> extends Future<V> {
 
@@ -29,11 +28,5 @@ public interface TransportFuture<V> extends Future<V> {
      * retrieves its result.
      */
     V txGet();
-
-    /**
-     * Waits if necessary for at most the given time for the computation
-     * to complete, and then retrieves its result, if available.
-     */
-    V txGet(long timeout, TimeUnit unit);
 }
 

+ 2 - 10
test/framework/src/main/java/org/elasticsearch/transport/nio/MockNioTransport.java

@@ -215,7 +215,7 @@ public class MockNioTransport extends TcpTransport {
 
         @Override
         public MockServerChannel createServerChannel(NioSelector selector, ServerSocketChannel channel) throws IOException {
-            MockServerChannel nioServerChannel = new MockServerChannel(profileName, channel);
+            MockServerChannel nioServerChannel = new MockServerChannel(channel);
             Consumer<Exception> exceptionHandler = (e) -> logger.error(() ->
                 new ParameterizedMessage("exception from server channel caught on transport layer [{}]", channel), e);
             ServerChannelContext context = new ServerChannelContext(nioServerChannel, this, selector, MockNioTransport.this::acceptChannel,
@@ -244,11 +244,8 @@ public class MockNioTransport extends TcpTransport {
 
     private static class MockServerChannel extends NioServerSocketChannel implements TcpServerChannel {
 
-        private final String profile;
-
-        MockServerChannel(String profile, ServerSocketChannel channel) {
+        MockServerChannel(ServerSocketChannel channel) {
             super(channel);
-            this.profile = profile;
         }
 
         @Override
@@ -256,11 +253,6 @@ public class MockNioTransport extends TcpTransport {
             getContext().closeChannel();
         }
 
-        @Override
-        public String getProfile() {
-            return profile;
-        }
-
         @Override
         public void addCloseListener(ActionListener<Void> listener) {
             addCloseListener(ActionListener.toBiConsumer(listener));

+ 1 - 1
x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java

@@ -177,7 +177,7 @@ public class SecurityNioTransport extends NioTransport {
 
         @Override
         public NioTcpServerChannel createServerChannel(NioSelector selector, ServerSocketChannel channel) throws IOException {
-            NioTcpServerChannel nioChannel = new NioTcpServerChannel(profileName, channel);
+            NioTcpServerChannel nioChannel = new NioTcpServerChannel(channel);
             Consumer<Exception> exceptionHandler = (e) -> onServerException(nioChannel, e);
             Consumer<NioSocketChannel> acceptor = SecurityNioTransport.this::acceptChannel;
             ServerChannelContext context = new ServerChannelContext(nioChannel, this, selector, acceptor, exceptionHandler);