Package org.elasticsearch.nio
Class ChannelFactory<ServerSocket extends NioServerSocketChannel,Socket extends NioSocketChannel>
- java.lang.Object
-
- org.elasticsearch.nio.ChannelFactory<ServerSocket,Socket>
-
public abstract class ChannelFactory<ServerSocket extends NioServerSocketChannel,Socket extends NioSocketChannel> extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classChannelFactory.RawChannelFactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedChannelFactory(boolean tcpNoDelay, boolean tcpKeepAlive, int tcpKeepIdle, int tcpKeepInterval, int tcpKeepCount, boolean tcpReuseAddress, int tcpSendBufferSize, int tcpReceiveBufferSize)This will create aChannelFactory.protectedChannelFactory(boolean tcpNoDelay, boolean tcpKeepAlive, int tcpKeepIdle, int tcpKeepInterval, int tcpKeepCount, boolean tcpReuseAddress, int tcpSendBufferSize, int tcpReceiveBufferSize, ChannelFactory.RawChannelFactory rawChannelFactory)This will create aChannelFactoryusing the raw channel factory passed to the constructor.
-
Method Summary
Modifier and Type Method Description SocketacceptNioChannel(java.nio.channels.SocketChannel rawChannel, java.util.function.Supplier<NioSelector> supplier)abstract SocketcreateChannel(NioSelector selector, java.nio.channels.SocketChannel channel, Config.Socket socketConfig)This method should return a newNioSocketChannelimplementation.abstract ServerSocketcreateServerChannel(NioSelector selector, java.nio.channels.ServerSocketChannel channel, Config.ServerSocket socketConfig)This method should return a newNioServerSocketChannelimplementation.protected java.net.InetSocketAddressgetRemoteAddress(java.nio.channels.SocketChannel rawChannel)SocketopenNioChannel(java.net.InetSocketAddress remoteAddress, java.util.function.Supplier<NioSelector> supplier)ServerSocketopenNioServerSocketChannel(java.net.InetSocketAddress localAddress, java.util.function.Supplier<NioSelector> supplier)
-
-
-
Constructor Detail
-
ChannelFactory
protected ChannelFactory(boolean tcpNoDelay, boolean tcpKeepAlive, int tcpKeepIdle, int tcpKeepInterval, int tcpKeepCount, boolean tcpReuseAddress, int tcpSendBufferSize, int tcpReceiveBufferSize)This will create aChannelFactory.
-
ChannelFactory
protected ChannelFactory(boolean tcpNoDelay, boolean tcpKeepAlive, int tcpKeepIdle, int tcpKeepInterval, int tcpKeepCount, boolean tcpReuseAddress, int tcpSendBufferSize, int tcpReceiveBufferSize, ChannelFactory.RawChannelFactory rawChannelFactory)This will create aChannelFactoryusing the raw channel factory passed to the constructor.
-
-
Method Detail
-
openNioChannel
public Socket openNioChannel(java.net.InetSocketAddress remoteAddress, java.util.function.Supplier<NioSelector> supplier) throws java.io.IOException
- Throws:
java.io.IOException
-
acceptNioChannel
public Socket acceptNioChannel(java.nio.channels.SocketChannel rawChannel, java.util.function.Supplier<NioSelector> supplier) throws java.io.IOException
- Throws:
java.io.IOException
-
openNioServerSocketChannel
public ServerSocket openNioServerSocketChannel(java.net.InetSocketAddress localAddress, java.util.function.Supplier<NioSelector> supplier) throws java.io.IOException
- Throws:
java.io.IOException
-
createChannel
public abstract Socket createChannel(NioSelector selector, java.nio.channels.SocketChannel channel, Config.Socket socketConfig) throws java.io.IOException
This method should return a newNioSocketChannelimplementation. When this method has returned, the channel should be fully created and setup. Read and write contexts and the channel exception handler should have been set.- Parameters:
selector- the channel will be registered withchannel- the raw channelsocketConfig- the socket config- Returns:
- the channel
- Throws:
java.io.IOException- related to the creation of the channel
-
createServerChannel
public abstract ServerSocket createServerChannel(NioSelector selector, java.nio.channels.ServerSocketChannel channel, Config.ServerSocket socketConfig) throws java.io.IOException
This method should return a newNioServerSocketChannelimplementation. When this method has returned, the channel should be fully created and setup.- Parameters:
selector- the channel will be registered withchannel- the raw channelsocketConfig- the socket config- Returns:
- the server channel
- Throws:
java.io.IOException- related to the creation of the channel
-
getRemoteAddress
protected java.net.InetSocketAddress getRemoteAddress(java.nio.channels.SocketChannel rawChannel) throws java.io.IOException- Throws:
java.io.IOException
-
-