Package io.netty.channel.epoll
Class AbstractEpollStreamChannel
- java.lang.Object
-
- io.netty.util.DefaultAttributeMap
-
- io.netty.channel.AbstractChannel
-
- io.netty.channel.epoll.AbstractEpollStreamChannel
-
- All Implemented Interfaces:
io.netty.channel.Channel,io.netty.channel.ChannelOutboundInvoker,io.netty.channel.socket.DuplexChannel,io.netty.channel.unix.UnixChannel,io.netty.util.AttributeMap,Comparable<io.netty.channel.Channel>
- Direct Known Subclasses:
EpollDomainSocketChannel,EpollSocketChannel
public abstract class AbstractEpollStreamChannel extends io.netty.channel.AbstractChannel implements io.netty.channel.socket.DuplexChannel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractEpollStreamChannel.SpliceInTask
-
Field Summary
Fields Modifier and Type Field Description protected booleanactiveprotected LinuxSocketsocket
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEpollStreamChannel(int fd)protectedAbstractEpollStreamChannel(io.netty.channel.Channel parent, int fd)protectedAbstractEpollStreamChannel(io.netty.channel.Channel parent, LinuxSocket fd, SocketAddress remote)protectedAbstractEpollStreamChannel(LinuxSocket fd, boolean active)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static voidcheckResolvable(InetSocketAddress addr)abstract EpollChannelConfigconfig()protected voiddoBeginRead()protected voiddoBind(SocketAddress local)protected voiddoClose()protected booleandoConnect(SocketAddress remoteAddress, SocketAddress localAddress)Connect to the remote peerprotected voiddoDeregister()protected voiddoDisconnect()protected intdoReadBytes(io.netty.buffer.ByteBuf byteBuf)Read bytes into the givenByteBufand return the amount.protected voiddoRegister(io.netty.channel.ChannelPromise promise)protected voiddoShutdownOutput()protected voiddoWrite(io.netty.channel.ChannelOutboundBuffer in)protected intdoWriteBytes(io.netty.channel.ChannelOutboundBuffer in, io.netty.buffer.ByteBuf buf)protected intdoWriteSingle(io.netty.channel.ChannelOutboundBuffer in)Attempt to write a single object.io.netty.channel.unix.FileDescriptorfd()protected ObjectfilterOutboundMessage(Object msg)booleanisActive()protected booleanisCompatible(io.netty.channel.EventLoop loop)booleanisInputShutdown()booleanisOpen()booleanisOutputShutdown()booleanisShutdown()protected SocketAddresslocalAddress0()io.netty.channel.ChannelMetadatametadata()protected io.netty.buffer.ByteBufnewDirectBuffer(io.netty.buffer.ByteBuf buf)Returns an off-heap copy of the specifiedByteBuf, and releases the original one.protected io.netty.buffer.ByteBufnewDirectBuffer(Object holder, io.netty.buffer.ByteBuf buf)Returns an off-heap copy of the specifiedByteBuf, and releases the specified holder.protected io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafenewUnsafe()protected io.netty.channel.IoRegistrationregistration()protected SocketAddressremoteAddress0()protected voidsetFlag(int flag)io.netty.channel.ChannelFutureshutdown()io.netty.channel.ChannelFutureshutdown(io.netty.channel.ChannelPromise promise)io.netty.channel.ChannelFutureshutdownInput()io.netty.channel.ChannelFutureshutdownInput(io.netty.channel.ChannelPromise promise)io.netty.channel.ChannelFutureshutdownOutput()io.netty.channel.ChannelFutureshutdownOutput(io.netty.channel.ChannelPromise promise)io.netty.channel.ChannelFuturespliceTo(AbstractEpollStreamChannel ch, int len)Splice from thisAbstractEpollStreamChannelto anotherAbstractEpollStreamChannel.io.netty.channel.ChannelFuturespliceTo(AbstractEpollStreamChannel ch, int len, io.netty.channel.ChannelPromise promise)Splice from thisAbstractEpollStreamChannelto anotherAbstractEpollStreamChannel.io.netty.channel.ChannelFuturespliceTo(io.netty.channel.unix.FileDescriptor ch, int offset, int len)Splice from thisAbstractEpollStreamChannelto anotherFileDescriptor.io.netty.channel.ChannelFuturespliceTo(io.netty.channel.unix.FileDescriptor ch, int offset, int len, io.netty.channel.ChannelPromise promise)Splice from thisAbstractEpollStreamChannelto anotherFileDescriptor.-
Methods inherited from class io.netty.channel.AbstractChannel
closeFuture, compareTo, doRegister, equals, eventLoop, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, localAddress, maxMessagesPerWrite, newChannelPipeline, newId, parent, pipeline, remoteAddress, toString, unsafe, validateFileRegion, voidPromise
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.channel.Channel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, closeFuture, config, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, eventLoop, flush, getOption, id, isActive, isOpen, isRegistered, isWritable, localAddress, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, parent, pipeline, read, remoteAddress, setOption, unsafe, voidPromise, write, write, writeAndFlush, writeAndFlush
-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Field Detail
-
socket
protected final LinuxSocket socket
-
active
protected volatile boolean active
-
-
Constructor Detail
-
AbstractEpollStreamChannel
protected AbstractEpollStreamChannel(io.netty.channel.Channel parent, int fd)
-
AbstractEpollStreamChannel
protected AbstractEpollStreamChannel(int fd)
-
AbstractEpollStreamChannel
protected AbstractEpollStreamChannel(io.netty.channel.Channel parent, LinuxSocket fd, SocketAddress remote)
-
AbstractEpollStreamChannel
protected AbstractEpollStreamChannel(LinuxSocket fd, boolean active)
-
-
Method Detail
-
newUnsafe
protected io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafe newUnsafe()
-
metadata
public io.netty.channel.ChannelMetadata metadata()
- Specified by:
metadatain interfaceio.netty.channel.Channel
-
spliceTo
public final io.netty.channel.ChannelFuture spliceTo(AbstractEpollStreamChannel ch, int len)
Splice from thisAbstractEpollStreamChannelto anotherAbstractEpollStreamChannel. Thelenis the number of bytes to splice. If usingInteger.MAX_VALUEit will splice until theChannelFuturewas canceled or it was failed. Please note:- both channels need to be registered to the same
EventLoop, otherwise anIllegalArgumentExceptionis thrown. EpollChannelConfig.getEpollMode()must beEpollMode.LEVEL_TRIGGEREDfor this and the targetAbstractEpollStreamChannel
- both channels need to be registered to the same
-
spliceTo
public final io.netty.channel.ChannelFuture spliceTo(AbstractEpollStreamChannel ch, int len, io.netty.channel.ChannelPromise promise)
Splice from thisAbstractEpollStreamChannelto anotherAbstractEpollStreamChannel. Thelenis the number of bytes to splice. If usingInteger.MAX_VALUEit will splice until theChannelFuturewas canceled or it was failed. Please note:- both channels need to be registered to the same
EventLoop, otherwise anIllegalArgumentExceptionis thrown. EpollChannelConfig.getEpollMode()must beEpollMode.LEVEL_TRIGGEREDfor this and the targetAbstractEpollStreamChannel
- both channels need to be registered to the same
-
spliceTo
public final io.netty.channel.ChannelFuture spliceTo(io.netty.channel.unix.FileDescriptor ch, int offset, int len)Splice from thisAbstractEpollStreamChannelto anotherFileDescriptor. Theoffsetis the offset for theFileDescriptorandlenis the number of bytes to splice. If usingInteger.MAX_VALUEit will splice until theChannelFuturewas canceled or it was failed. Please note:EpollChannelConfig.getEpollMode()must beEpollMode.LEVEL_TRIGGEREDfor thisAbstractEpollStreamChannel- the
FileDescriptorwill not be closed after theChannelFutureis notified - this channel must be registered to an event loop or
IllegalStateExceptionwill be thrown.
-
spliceTo
public final io.netty.channel.ChannelFuture spliceTo(io.netty.channel.unix.FileDescriptor ch, int offset, int len, io.netty.channel.ChannelPromise promise)Splice from thisAbstractEpollStreamChannelto anotherFileDescriptor. Theoffsetis the offset for theFileDescriptorandlenis the number of bytes to splice. If usingInteger.MAX_VALUEit will splice until theChannelFuturewas canceled or it was failed. Please note:EpollChannelConfig.getEpollMode()must beEpollMode.LEVEL_TRIGGEREDfor thisAbstractEpollStreamChannel- the
FileDescriptorwill not be closed after theChannelPromiseis notified - this channel must be registered to an event loop or
IllegalStateExceptionwill be thrown.
-
doWrite
protected void doWrite(io.netty.channel.ChannelOutboundBuffer in) throws Exception- Specified by:
doWritein classio.netty.channel.AbstractChannel- Throws:
Exception
-
doWriteSingle
protected int doWriteSingle(io.netty.channel.ChannelOutboundBuffer in) throws ExceptionAttempt to write a single object.- Parameters:
in- the collection which contains objects to write.- Returns:
- The value that should be decremented from the write quantum which starts at
ChannelConfig.getWriteSpinCount(). The typical use cases are as follows:- 0 - if no write was attempted. This is appropriate if an empty
ByteBuf(or other empty content) is encountered - 1 - if a single call to write data was made to the OS
ChannelUtils.WRITE_STATUS_SNDBUF_FULL- if an attempt to write data was made to the OS, but no data was accepted
- 0 - if no write was attempted. This is appropriate if an empty
- Throws:
Exception- If an I/O error occurs.
-
filterOutboundMessage
protected Object filterOutboundMessage(Object msg)
- Overrides:
filterOutboundMessagein classio.netty.channel.AbstractChannel
-
doShutdownOutput
protected final void doShutdownOutput() throws Exception- Overrides:
doShutdownOutputin classio.netty.channel.AbstractChannel- Throws:
Exception
-
isOutputShutdown
public boolean isOutputShutdown()
- Specified by:
isOutputShutdownin interfaceio.netty.channel.socket.DuplexChannel
-
isInputShutdown
public boolean isInputShutdown()
- Specified by:
isInputShutdownin interfaceio.netty.channel.socket.DuplexChannel
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfaceio.netty.channel.socket.DuplexChannel
-
shutdownOutput
public io.netty.channel.ChannelFuture shutdownOutput()
- Specified by:
shutdownOutputin interfaceio.netty.channel.socket.DuplexChannel
-
shutdownOutput
public io.netty.channel.ChannelFuture shutdownOutput(io.netty.channel.ChannelPromise promise)
- Specified by:
shutdownOutputin interfaceio.netty.channel.socket.DuplexChannel
-
shutdownInput
public io.netty.channel.ChannelFuture shutdownInput()
- Specified by:
shutdownInputin interfaceio.netty.channel.socket.DuplexChannel
-
shutdownInput
public io.netty.channel.ChannelFuture shutdownInput(io.netty.channel.ChannelPromise promise)
- Specified by:
shutdownInputin interfaceio.netty.channel.socket.DuplexChannel
-
shutdown
public io.netty.channel.ChannelFuture shutdown()
- Specified by:
shutdownin interfaceio.netty.channel.socket.DuplexChannel
-
shutdown
public io.netty.channel.ChannelFuture shutdown(io.netty.channel.ChannelPromise promise)
- Specified by:
shutdownin interfaceio.netty.channel.socket.DuplexChannel
-
setFlag
protected void setFlag(int flag) throws IOException- Throws:
IOException
-
registration
protected final io.netty.channel.IoRegistration registration()
-
fd
public final io.netty.channel.unix.FileDescriptor fd()
- Specified by:
fdin interfaceio.netty.channel.unix.UnixChannel
-
config
public abstract EpollChannelConfig config()
- Specified by:
configin interfaceio.netty.channel.Channel
-
isActive
public boolean isActive()
- Specified by:
isActivein interfaceio.netty.channel.Channel
-
doDisconnect
protected void doDisconnect() throws Exception- Specified by:
doDisconnectin classio.netty.channel.AbstractChannel- Throws:
Exception
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfaceio.netty.channel.Channel
-
doDeregister
protected void doDeregister() throws Exception- Overrides:
doDeregisterin classio.netty.channel.AbstractChannel- Throws:
Exception
-
isCompatible
protected boolean isCompatible(io.netty.channel.EventLoop loop)
- Specified by:
isCompatiblein classio.netty.channel.AbstractChannel
-
doBeginRead
protected void doBeginRead() throws Exception- Specified by:
doBeginReadin classio.netty.channel.AbstractChannel- Throws:
Exception
-
doRegister
protected void doRegister(io.netty.channel.ChannelPromise promise)
- Overrides:
doRegisterin classio.netty.channel.AbstractChannel
-
newDirectBuffer
protected final io.netty.buffer.ByteBuf newDirectBuffer(io.netty.buffer.ByteBuf buf)
Returns an off-heap copy of the specifiedByteBuf, and releases the original one.
-
newDirectBuffer
protected final io.netty.buffer.ByteBuf newDirectBuffer(Object holder, io.netty.buffer.ByteBuf buf)
Returns an off-heap copy of the specifiedByteBuf, and releases the specified holder. The caller must ensure that the holder releases the originalByteBufwhen the holder is released by this method.
-
checkResolvable
protected static void checkResolvable(InetSocketAddress addr)
-
doReadBytes
protected final int doReadBytes(io.netty.buffer.ByteBuf byteBuf) throws ExceptionRead bytes into the givenByteBufand return the amount.- Throws:
Exception
-
doWriteBytes
protected final int doWriteBytes(io.netty.channel.ChannelOutboundBuffer in, io.netty.buffer.ByteBuf buf) throws Exception- Throws:
Exception
-
doBind
protected void doBind(SocketAddress local) throws Exception
- Specified by:
doBindin classio.netty.channel.AbstractChannel- Throws:
Exception
-
doConnect
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
Connect to the remote peer- Throws:
Exception
-
localAddress0
protected SocketAddress localAddress0()
- Specified by:
localAddress0in classio.netty.channel.AbstractChannel
-
remoteAddress0
protected SocketAddress remoteAddress0()
- Specified by:
remoteAddress0in classio.netty.channel.AbstractChannel
-
-