Package io.netty.channel.epoll
Class AbstractEpollChannel
- java.lang.Object
-
- io.netty.util.DefaultAttributeMap
-
- io.netty.channel.AbstractChannel
-
- io.netty.channel.epoll.AbstractEpollChannel
-
- All Implemented Interfaces:
Channel,ChannelOutboundInvoker,UnixChannel,AttributeMap,java.lang.Comparable<Channel>
- Direct Known Subclasses:
AbstractEpollServerChannel,AbstractEpollStreamChannel,EpollDatagramChannel,EpollDomainDatagramChannel
abstract class AbstractEpollChannel extends AbstractChannel implements UnixChannel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractEpollChannel.AbstractEpollUnsafe-
Nested classes/interfaces inherited from class io.netty.channel.AbstractChannel
AbstractChannel.AbstractUnsafe
-
Nested classes/interfaces inherited from interface io.netty.channel.Channel
Channel.Unsafe
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveprivate ChannelPromiseconnectPromiseThe future of the current connection attempt.private Future<?>connectTimeoutFuture(package private) booleanepollInReadyRunnablePendingprotected intflags(package private) booleaninputClosedSeenErrorOnReadprivate java.net.SocketAddresslocalprivate static ChannelMetadataMETADATAprivate java.net.SocketAddressremoteprivate java.net.SocketAddressrequestedRemoteAddressprotected LinuxSocketsocket
-
Constructor Summary
Constructors Constructor Description AbstractEpollChannel(Channel parent, LinuxSocket fd, boolean active)AbstractEpollChannel(Channel parent, LinuxSocket fd, java.net.SocketAddress remote)AbstractEpollChannel(LinuxSocket fd)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static voidcheckResolvable(java.net.InetSocketAddress addr)(package private) voidclearEpollIn()(package private) voidclearFlag(int flag)abstract EpollChannelConfigconfig()Returns the configuration of this channel.protected voiddoBeginRead()Schedule a read operation.protected voiddoBind(java.net.SocketAddress local)Bind theChannelto theSocketAddressprotected voiddoClose()Close theChannelprotected booleandoConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)Connect to the remote peer(package private) booleandoConnect0(java.net.SocketAddress remote)protected voiddoDeregister()protected voiddoDisconnect()Disconnect thisChannelfrom its remote peerprotected intdoReadBytes(ByteBuf byteBuf)Read bytes into the givenByteBufand return the amount.protected voiddoRegister()protected intdoWriteBytes(ChannelOutboundBuffer in, ByteBuf buf)(package private) longdoWriteOrSendBytes(ByteBuf data, java.net.InetSocketAddress remoteAddress, boolean fastOpen)Write bytes to the socket, with or without a remote address.FileDescriptorfd()Returns theFileDescriptorthat is used by thisChannel.booleanisActive()Returntrueif theChannelis active and so connected.private static booleanisAllowHalfClosure(ChannelConfig config)protected booleanisCompatible(EventLoop loop)Returntrueif the givenEventLoopis compatible with this instance.(package private) booleanisFlagSet(int flag)booleanisOpen()Returnstrueif theChannelis open and may get active later(package private) static booleanisSoErrorZero(Socket fd)protected java.net.SocketAddresslocalAddress0()Returns theSocketAddresswhich is bound locally.ChannelMetadatametadata()private voidmodifyEvents()protected ByteBufnewDirectBuffer(ByteBuf buf)Returns an off-heap copy of the specifiedByteBuf, and releases the original one.protected ByteBufnewDirectBuffer(java.lang.Object holder, ByteBuf buf)Returns an off-heap copy of the specifiedByteBuf, and releases the specified holder.private static ByteBufnewDirectBuffer0(java.lang.Object holder, ByteBuf buf, ByteBufAllocator alloc, int capacity)protected abstract AbstractEpollChannel.AbstractEpollUnsafenewUnsafe()Create a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannelprotected java.net.SocketAddressremoteAddress0()Return theSocketAddresswhich theChannelis connected to.(package private) voidresetCachedAddresses()protected voidsetFlag(int flag)(package private) booleanshouldBreakEpollInReady(ChannelConfig config)-
Methods inherited from class io.netty.channel.AbstractChannel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, compareTo, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, doShutdownOutput, doWrite, equals, eventLoop, filterOutboundMessage, flush, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, isWritable, localAddress, maxMessagesPerWrite, newChannelPipeline, newFailedFuture, newId, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, toString, unsafe, validateFileRegion, voidPromise, write, write, writeAndFlush, writeAndFlush
-
Methods inherited from class io.netty.util.DefaultAttributeMap
attr, hasAttr
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.util.AttributeMap
attr, hasAttr
-
Methods inherited from interface io.netty.channel.Channel
alloc, bytesBeforeUnwritable, bytesBeforeWritable, closeFuture, eventLoop, flush, id, isRegistered, isWritable, localAddress, parent, pipeline, read, remoteAddress, unsafe
-
Methods inherited from interface io.netty.channel.ChannelOutboundInvoker
bind, bind, close, close, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, voidPromise, write, write, writeAndFlush, writeAndFlush
-
-
-
-
Field Detail
-
METADATA
private static final ChannelMetadata METADATA
-
socket
protected final LinuxSocket socket
-
connectPromise
private ChannelPromise connectPromise
The future of the current connection attempt. If not null, subsequent connection attempts will fail.
-
connectTimeoutFuture
private Future<?> connectTimeoutFuture
-
requestedRemoteAddress
private java.net.SocketAddress requestedRemoteAddress
-
local
private volatile java.net.SocketAddress local
-
remote
private volatile java.net.SocketAddress remote
-
flags
protected int flags
-
inputClosedSeenErrorOnRead
boolean inputClosedSeenErrorOnRead
-
epollInReadyRunnablePending
boolean epollInReadyRunnablePending
-
active
protected volatile boolean active
-
-
Constructor Detail
-
AbstractEpollChannel
AbstractEpollChannel(LinuxSocket fd)
-
AbstractEpollChannel
AbstractEpollChannel(Channel parent, LinuxSocket fd, boolean active)
-
AbstractEpollChannel
AbstractEpollChannel(Channel parent, LinuxSocket fd, java.net.SocketAddress remote)
-
-
Method Detail
-
isSoErrorZero
static boolean isSoErrorZero(Socket fd)
-
setFlag
protected void setFlag(int flag) throws java.io.IOException- Throws:
java.io.IOException
-
clearFlag
void clearFlag(int flag) throws java.io.IOException- Throws:
java.io.IOException
-
isFlagSet
boolean isFlagSet(int flag)
-
fd
public final FileDescriptor fd()
Description copied from interface:UnixChannelReturns theFileDescriptorthat is used by thisChannel.- Specified by:
fdin interfaceUnixChannel
-
config
public abstract EpollChannelConfig config()
Description copied from interface:ChannelReturns the configuration of this channel.
-
isActive
public boolean isActive()
Description copied from interface:ChannelReturntrueif theChannelis active and so connected.
-
metadata
public ChannelMetadata metadata()
Description copied from interface:Channel
-
doClose
protected void doClose() throws java.lang.ExceptionDescription copied from class:AbstractChannelClose theChannel- Specified by:
doClosein classAbstractChannel- Throws:
java.lang.Exception
-
resetCachedAddresses
void resetCachedAddresses()
-
doDisconnect
protected void doDisconnect() throws java.lang.ExceptionDescription copied from class:AbstractChannelDisconnect thisChannelfrom its remote peer- Specified by:
doDisconnectin classAbstractChannel- Throws:
java.lang.Exception
-
isCompatible
protected boolean isCompatible(EventLoop loop)
Description copied from class:AbstractChannelReturntrueif the givenEventLoopis compatible with this instance.- Specified by:
isCompatiblein classAbstractChannel
-
isOpen
public boolean isOpen()
Description copied from interface:ChannelReturnstrueif theChannelis open and may get active later
-
doDeregister
protected void doDeregister() throws java.lang.ExceptionDescription copied from class:AbstractChannel- Overrides:
doDeregisterin classAbstractChannel- Throws:
java.lang.Exception
-
doBeginRead
protected final void doBeginRead() throws java.lang.ExceptionDescription copied from class:AbstractChannelSchedule a read operation.- Specified by:
doBeginReadin classAbstractChannel- Throws:
java.lang.Exception
-
shouldBreakEpollInReady
final boolean shouldBreakEpollInReady(ChannelConfig config)
-
isAllowHalfClosure
private static boolean isAllowHalfClosure(ChannelConfig config)
-
clearEpollIn
final void clearEpollIn()
-
modifyEvents
private void modifyEvents() throws java.io.IOException- Throws:
java.io.IOException
-
doRegister
protected void doRegister() throws java.lang.ExceptionDescription copied from class:AbstractChannelIs called after theChannelis registered with itsEventLoopas part of the register process. Sub-classes may override this method- Overrides:
doRegisterin classAbstractChannel- Throws:
java.lang.Exception
-
newUnsafe
protected abstract AbstractEpollChannel.AbstractEpollUnsafe newUnsafe()
Description copied from class:AbstractChannelCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannel- Specified by:
newUnsafein classAbstractChannel
-
newDirectBuffer
protected final ByteBuf newDirectBuffer(ByteBuf buf)
Returns an off-heap copy of the specifiedByteBuf, and releases the original one.
-
newDirectBuffer0
private static ByteBuf newDirectBuffer0(java.lang.Object holder, ByteBuf buf, ByteBufAllocator alloc, int capacity)
-
checkResolvable
protected static void checkResolvable(java.net.InetSocketAddress addr)
-
doReadBytes
protected final int doReadBytes(ByteBuf byteBuf) throws java.lang.Exception
Read bytes into the givenByteBufand return the amount.- Throws:
java.lang.Exception
-
doWriteBytes
protected final int doWriteBytes(ChannelOutboundBuffer in, ByteBuf buf) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doWriteOrSendBytes
final long doWriteOrSendBytes(ByteBuf data, java.net.InetSocketAddress remoteAddress, boolean fastOpen) throws java.io.IOException
Write bytes to the socket, with or without a remote address. Used for datagram and TCP client fast open writes.- Throws:
java.io.IOException
-
doBind
protected void doBind(java.net.SocketAddress local) throws java.lang.ExceptionDescription copied from class:AbstractChannelBind theChannelto theSocketAddress- Specified by:
doBindin classAbstractChannel- Throws:
java.lang.Exception
-
doConnect
protected boolean doConnect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress) throws java.lang.ExceptionConnect to the remote peer- Throws:
java.lang.Exception
-
doConnect0
boolean doConnect0(java.net.SocketAddress remote) throws java.lang.Exception- Throws:
java.lang.Exception
-
localAddress0
protected java.net.SocketAddress localAddress0()
Description copied from class:AbstractChannelReturns theSocketAddresswhich is bound locally.- Specified by:
localAddress0in classAbstractChannel
-
remoteAddress0
protected java.net.SocketAddress remoteAddress0()
Description copied from class:AbstractChannelReturn theSocketAddresswhich theChannelis connected to.- Specified by:
remoteAddress0in classAbstractChannel
-
-