Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ public NioShutdown(Logger logger) {
this.logger = logger;
}

void orderlyShutdown(OpenChannels openChannels, NioClient client, ArrayList<AcceptingSelector> acceptors,
ArrayList<SocketSelector> socketSelectors) {
// Close the client. This ensures that no new send connections will be opened. Client could be null if exception was
// throw on start up
if (client != null) {
client.close();
}
void orderlyShutdown(OpenChannels openChannels, ArrayList<AcceptingSelector> acceptors, ArrayList<SocketSelector> socketSelectors) {

// Start by closing the server channels. Once these are closed, we are guaranteed to no accept new connections
openChannels.closeServerChannels();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public class NioTransport extends TcpTransport<NioChannel> {
private final ConcurrentMap<String, ChannelFactory> profileToChannelFactory = newConcurrentMap();
private final ArrayList<AcceptingSelector> acceptors = new ArrayList<>();
private final ArrayList<SocketSelector> socketSelectors = new ArrayList<>();
private NioClient client;
private RoundRobinSelectorSupplier clientSelectorSupplier;
private ChannelFactory clientChannelFactory;
private int acceptorNumber;

public NioTransport(Settings settings, ThreadPool threadPool, NetworkService networkService, BigArrays bigArrays,
Expand Down Expand Up @@ -111,10 +112,8 @@ protected void sendMessage(NioChannel channel, BytesReference reference, ActionL
@Override
protected NioChannel initiateChannel(DiscoveryNode node, TimeValue connectTimeout, ActionListener<NioChannel> connectListener)
throws IOException {
NioSocketChannel channel = client.initiateConnection(node.getAddress().address());
if (channel == null) {
throw new ElasticsearchException("client is shutdown");
}
NioSocketChannel channel = clientChannelFactory.openNioChannel(node.getAddress().address(), clientSelectorSupplier.get());
openChannels.clientChannelOpened(channel);
channel.addConnectListener(connectListener);
return channel;
}
Expand All @@ -137,7 +136,8 @@ protected void doStart() {
}
}

client = createClient();
clientSelectorSupplier = new RoundRobinSelectorSupplier(socketSelectors);
clientChannelFactory = new ChannelFactory(new ProfileSettings(settings, "default"), contextSetter);

if (NetworkService.NETWORK_SERVER.get(settings)) {
int acceptorCount = NioTransport.NIO_ACCEPTOR_COUNT.get(settings);
Expand Down Expand Up @@ -178,7 +178,7 @@ protected void doStart() {
@Override
protected void stopInternal() {
NioShutdown nioShutdown = new NioShutdown(logger);
nioShutdown.orderlyShutdown(openChannels, client, acceptors, socketSelectors);
nioShutdown.orderlyShutdown(openChannels, acceptors, socketSelectors);

profileToChannelFactory.clear();
socketSelectors.clear();
Expand All @@ -193,10 +193,4 @@ final void exceptionCaught(NioSocketChannel channel, Throwable cause) {
final Throwable t = unwrapped != null ? unwrapped : cause;
onException(channel, t instanceof Exception ? (Exception) t : new ElasticsearchException(t));
}

private NioClient createClient() {
Supplier<SocketSelector> selectorSupplier = new RoundRobinSelectorSupplier(socketSelectors);
ChannelFactory channelFactory = new ChannelFactory(new ProfileSettings(settings, "default"), contextSetter);
return new NioClient(openChannels, selectorSupplier, channelFactory);
}
}

This file was deleted.