Internal: clean up named writeable registry handling in netty transport classes

There are some leftovers around usage of NamedWriteableRegistry in our branch compared to master, just because the registry was added first here, then backported to master, and something didn't go completely right during the final merge.
This commit is contained in:
javanna 2015-08-28 09:57:39 +02:00 committed by Luca Cavanna
parent 24e53b5f8f
commit 6307738406
4 changed files with 6 additions and 17 deletions

View File

@ -25,8 +25,6 @@ import org.elasticsearch.common.component.Lifecycle;
import org.elasticsearch.common.compress.Compressor; import org.elasticsearch.common.compress.Compressor;
import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.compress.CompressorFactory;
import org.elasticsearch.common.compress.NotCompressedException; import org.elasticsearch.common.compress.NotCompressedException;
import org.elasticsearch.common.io.stream.FilterStreamInput;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput; import org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
@ -52,19 +50,13 @@ public class MessageChannelHandler extends SimpleChannelUpstreamHandler {
protected final TransportServiceAdapter transportServiceAdapter; protected final TransportServiceAdapter transportServiceAdapter;
protected final NettyTransport transport; protected final NettyTransport transport;
protected final String profileName; protected final String profileName;
private final NamedWriteableRegistry namedWriteableRegistry;
public MessageChannelHandler(NettyTransport transport, ESLogger logger, String profileName) { public MessageChannelHandler(NettyTransport transport, ESLogger logger, String profileName) {
this(transport, logger, profileName, new NamedWriteableRegistry());
}
public MessageChannelHandler(NettyTransport transport, ESLogger logger, String profileName, NamedWriteableRegistry namedWriteableRegistry) {
this.threadPool = transport.threadPool(); this.threadPool = transport.threadPool();
this.transportServiceAdapter = transport.transportServiceAdapter(); this.transportServiceAdapter = transport.transportServiceAdapter();
this.transport = transport; this.transport = transport;
this.logger = logger; this.logger = logger;
this.profileName = profileName; this.profileName = profileName;
this.namedWriteableRegistry = namedWriteableRegistry;
} }
@Override @Override

View File

@ -1070,7 +1070,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
} }
public ChannelPipelineFactory configureServerChannelPipelineFactory(String name, Settings settings) { public ChannelPipelineFactory configureServerChannelPipelineFactory(String name, Settings settings) {
return new ServerChannelPipelineFactory(this, name, settings, namedWriteableRegistry); return new ServerChannelPipelineFactory(this, name, settings);
} }
protected static class ServerChannelPipelineFactory implements ChannelPipelineFactory { protected static class ServerChannelPipelineFactory implements ChannelPipelineFactory {
@ -1078,13 +1078,11 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
protected final NettyTransport nettyTransport; protected final NettyTransport nettyTransport;
protected final String name; protected final String name;
protected final Settings settings; protected final Settings settings;
protected final NamedWriteableRegistry namedWriteableRegistry;
public ServerChannelPipelineFactory(NettyTransport nettyTransport, String name, Settings settings, NamedWriteableRegistry namedWriteableRegistry) { public ServerChannelPipelineFactory(NettyTransport nettyTransport, String name, Settings settings) {
this.nettyTransport = nettyTransport; this.nettyTransport = nettyTransport;
this.name = name; this.name = name;
this.settings = settings; this.settings = settings;
this.namedWriteableRegistry = namedWriteableRegistry;
} }
@Override @Override
@ -1103,7 +1101,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
sizeHeader.setMaxCumulationBufferComponents(nettyTransport.maxCompositeBufferComponents); sizeHeader.setMaxCumulationBufferComponents(nettyTransport.maxCompositeBufferComponents);
} }
channelPipeline.addLast("size", sizeHeader); channelPipeline.addLast("size", sizeHeader);
channelPipeline.addLast("dispatcher", new MessageChannelHandler(nettyTransport, nettyTransport.logger, name, namedWriteableRegistry)); channelPipeline.addLast("dispatcher", new MessageChannelHandler(nettyTransport, nettyTransport.logger, name));
return channelPipeline; return channelPipeline;
} }
} }

View File

@ -52,7 +52,6 @@ public abstract class AbstractSimpleTransportTests extends ESTestCase {
protected ThreadPool threadPool; protected ThreadPool threadPool;
protected static final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry();
protected static final Version version0 = Version.fromId(/*0*/99); protected static final Version version0 = Version.fromId(/*0*/99);
protected DiscoveryNode nodeA; protected DiscoveryNode nodeA;
protected MockTransportService serviceA; protected MockTransportService serviceA;

View File

@ -112,15 +112,15 @@ public class NettyTransportIT extends ESIntegTestCase {
@Override @Override
public ChannelPipelineFactory configureServerChannelPipelineFactory(String name, Settings groupSettings) { public ChannelPipelineFactory configureServerChannelPipelineFactory(String name, Settings groupSettings) {
return new ErrorPipelineFactory(this, name, groupSettings, namedWriteableRegistry); return new ErrorPipelineFactory(this, name, groupSettings);
} }
private static class ErrorPipelineFactory extends ServerChannelPipelineFactory { private static class ErrorPipelineFactory extends ServerChannelPipelineFactory {
private final ESLogger logger; private final ESLogger logger;
public ErrorPipelineFactory(ExceptionThrowingNettyTransport exceptionThrowingNettyTransport, String name, Settings groupSettings, NamedWriteableRegistry namedWriteableRegistry) { public ErrorPipelineFactory(ExceptionThrowingNettyTransport exceptionThrowingNettyTransport, String name, Settings groupSettings) {
super(exceptionThrowingNettyTransport, name, groupSettings, namedWriteableRegistry); super(exceptionThrowingNettyTransport, name, groupSettings);
this.logger = exceptionThrowingNettyTransport.logger; this.logger = exceptionThrowingNettyTransport.logger;
} }