Class AbstractNioByteChannel
java.lang.Object
io.netty.util.DefaultAttributeMap
io.netty.channel.AbstractChannel
io.netty.channel.nio.AbstractNioChannel
io.netty.channel.nio.AbstractNioByteChannel
- All Implemented Interfaces:
Channel, ChannelOutboundInvoker, AttributeMap, Comparable<Channel>
- Direct Known Subclasses:
NioDomainSocketChannel, NioSocketChannel, NioUdtByteConnectorChannel
AbstractNioChannel base class for Channels that operate on bytes.-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class AbstractNioChannel
AbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafeModifier and TypeClassDescriptionprotected classstatic interfaceSpecialChannel.Unsafesub-type which allows to access the underlyingSelectableChannelNested classes/interfaces inherited from class AbstractChannel
AbstractChannel.AbstractUnsafeModifier and TypeClassDescriptionprotected classChannel.Unsafeimplementation which sub-classes must extend and use.Nested classes/interfaces inherited from interface Channel
Channel.UnsafeModifier and TypeInterfaceDescriptionstatic interfaceUnsafe operations that should never be called from user-code. -
Field Summary
Fields inherited from class AbstractNioChannel
readInterestOp, readOps -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNioByteChannel(Channel parent, SelectableChannel ch) Create a new instance -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidprotected abstract intdoReadBytes(ByteBuf buf) Read bytes into the givenByteBufand return the amount.protected voidFlush the content of the given buffer to the remote peer.protected final intWrite objects to the OS.protected abstract intdoWriteBytes(ByteBuf buf) protected abstract longdoWriteFileRegion(FileRegion region) Write aFileRegionprotected final ObjectInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.protected final voidincompleteWrite(boolean setOpWrite) protected booleanmetadata()protected AbstractNioChannel.AbstractNioUnsafeCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannelprotected final voidprotected abstract ChannelFutureShutdown the input side of the channel.Methods inherited from class AbstractNioChannel
addAndSubmit, clearReadPending, doBeginRead, doClose, doConnect, doDeregister, doFinishConnect, doRegister, isCompatible, isOpen, isReadPending, javaChannel, newDirectBuffer, newDirectBuffer, registration, removeAndSubmit, selectionKey, setReadPending, unsafeModifier and TypeMethodDescriptionprotected voidaddAndSubmit(NioIoOps addOps) protected final voidSet read pending tofalse.protected voidSchedule a read operation.protected voiddoClose()Close theChannelprotected abstract booleandoConnect(SocketAddress remoteAddress, SocketAddress localAddress) Connect to the remote peerprotected voidprotected abstract voidFinish the connectprotected voiddoRegister(ChannelPromise promise) protected booleanisCompatible(EventLoop loop) Returntrueif the givenEventLoopis compatible with this instance.booleanisOpen()Returnstrueif theChannelis open and may get active laterprotected booleanDeprecated.No longer supported.protected SelectableChannelprotected final ByteBufnewDirectBuffer(ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf, and releases the original one.protected final ByteBufnewDirectBuffer(ReferenceCounted holder, ByteBuf buf) Returns an off-heap copy of the specifiedByteBuf, and releases the specified holder.protected IoRegistrationprotected voidremoveAndSubmit(NioIoOps removeOps) protected SelectionKeyDeprecated.useAbstractNioChannel.registration.protected voidsetReadPending(boolean readPending) Deprecated.UseAbstractNioChannel.clearReadPending()if appropriate instead.unsafe()Returns an internal-use-only object that provides unsafe operations.Methods inherited from class AbstractChannel
closeFuture, compareTo, doBind, doDisconnect, doRegister, doShutdownOutput, equals, eventLoop, hashCode, id, invalidateLocalAddress, invalidateRemoteAddress, isRegistered, localAddress, localAddress0, maxMessagesPerWrite, newChannelPipeline, newId, parent, pipeline, remoteAddress, remoteAddress0, toString, validateFileRegion, voidPromiseModifier and TypeMethodDescriptionReturns theChannelFuturewhich will be notified when this channel is closed.final intprotected abstract voiddoBind(SocketAddress localAddress) Bind theChannelto theSocketAddressprotected abstract voidDisconnect thisChannelfrom its remote peerprotected voidDeprecated.protected voidCalled when conditions justify shutting down the output portion of the channel.final booleanReturnstrueif and only if the specified object is identical with this channel (i.e:this == o).final inthashCode()Returns the ID of this channel.final ChannelIdid()Returns the globally unique identifier of thisChannel.protected voidDeprecated.no use-case for this.protected voidDeprecated.no use-case for this.booleanReturns the local address where this channel is bound to.protected abstract SocketAddressReturns theSocketAddresswhich is bound locally.protected final intprotected DefaultChannelPipelineReturns a newDefaultChannelPipelineinstance.protected ChannelIdnewId()Returns a newDefaultChannelIdinstance.parent()Returns the parent of this channel.pipeline()Return the assignedChannelPipeline.Returns the remote address where this channel is connected to.protected abstract SocketAddressReturn theSocketAddresswhich theChannelis connected to.toString()Returns theStringrepresentation of this channel.protected voidvalidateFileRegion(DefaultFileRegion region, long position) final ChannelPromiseReturn a special ChannelPromise which can be reused for different operations.Methods inherited from class DefaultAttributeMap
attr, hasAttrModifier and TypeMethodDescription<T> Attribute<T> attr(AttributeKey<T> key) Get theAttributefor the givenAttributeKey.<T> booleanhasAttr(AttributeKey<T> key) Methods inherited from interface Channel
alloc, bind, bind, bytesBeforeUnwritable, bytesBeforeWritable, close, close, config, connect, connect, connect, connect, deregister, deregister, disconnect, disconnect, flush, getOption, isActive, isWritable, newFailedFuture, newProgressivePromise, newPromise, newSucceededFuture, read, setOption, write, write, writeAndFlush, writeAndFlushModifier and TypeMethodDescriptiondefault ByteBufAllocatoralloc()Return the assignedByteBufAllocatorwhich will be used to allocateByteBufs.default ChannelFuturebind(SocketAddress localAddress) Request to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFuturebind(SocketAddress localAddress, ChannelPromise promise) Request to bind to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default longGet how many bytes can be written untilChannel.isWritable()returnsfalse.default longGet how many bytes must be drained from underlying buffers untilChannel.isWritable()returnstrue.default ChannelFutureclose()Request to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureclose(ChannelPromise promise) Request to close theChanneland notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.config()Returns the configuration of this channel.default ChannelFutureconnect(SocketAddress remoteAddress) Request to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureconnect(SocketAddress remoteAddress, ChannelPromise promise) Request to connect to the givenSocketAddressand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureconnect(SocketAddress remoteAddress, SocketAddress localAddress) Request to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureconnect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Request to connect to the givenSocketAddresswhile bind to the localAddress and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureRequest to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFuturederegister(ChannelPromise promise) Request to deregister from the previous assignedEventExecutorand notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFutureRequest to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default ChannelFuturedisconnect(ChannelPromise promise) Request to disconnect from the remote peer and notify theChannelFutureonce the operation completes, either because the operation was successful or because of an error.default Channelflush()Request to flush all pending messages via this ChannelOutboundInvoker.default <T> TgetOption(ChannelOption<T> option) Return the value of the givenChannelOptionbooleanisActive()Returntrueif theChannelis active and so connected.default booleanReturnstrueif and only if the I/O thread will perform the requested write operation immediately.default ChannelFuturenewFailedFuture(Throwable cause) Create a newChannelFuturewhich is marked as failed already.default ChannelProgressivePromiseReturn an newChannelProgressivePromisedefault ChannelPromiseReturn a newChannelPromise.default ChannelFutureCreate a newChannelFuturewhich is marked as succeeded already.default Channelread()Request to Read data from theChannelinto the first inbound buffer, triggers anChannelInboundHandler.channelRead(ChannelHandlerContext, Object)event if data was read, and triggers achannelReadCompleteevent so the handler can decide to continue reading.default <T> booleansetOption(ChannelOption<T> option, T value) Sets a configuration property with the specified name and value.default ChannelFutureRequest to write a message via thisChannelHandlerContextthrough theChannelPipeline.default ChannelFuturewrite(Object msg, ChannelPromise promise) Request to write a message via thisChannelHandlerContextthrough theChannelPipeline.default ChannelFuturewriteAndFlush(Object msg) Shortcut for callChannelOutboundInvoker.write(Object)andChannelOutboundInvoker.flush().default ChannelFuturewriteAndFlush(Object msg, ChannelPromise promise) Shortcut for callChannelOutboundInvoker.write(Object, ChannelPromise)andChannelOutboundInvoker.flush().
-
Constructor Details
-
AbstractNioByteChannel
Create a new instance- Parameters:
parent- the parentChannelby which this instance was created. May benullch- the underlyingSelectableChannelon which it operates
-
-
Method Details
-
shutdownInput
Shutdown the input side of the channel. -
isInputShutdown0
protected boolean isInputShutdown0() -
newUnsafe
Description copied from class:AbstractChannelCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannel- Specified by:
newUnsafein classAbstractChannel
-
metadata
Description copied from interface:Channel -
doWrite0
Write objects to the OS.- 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 exception occurs during write.
-
doWrite
Description copied from class:AbstractChannelFlush the content of the given buffer to the remote peer.- Specified by:
doWritein classAbstractChannel- Throws:
Exception
-
filterOutboundMessage
Description copied from class:AbstractChannelInvoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another. (e.g. heap buffer -> direct buffer)- Overrides:
filterOutboundMessagein classAbstractChannel
-
incompleteWrite
protected final void incompleteWrite(boolean setOpWrite) -
doWriteFileRegion
Write aFileRegion- Parameters:
region- theFileRegionfrom which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
Exception
-
doReadBytes
-
doWriteBytes
-
setOpWrite
protected final void setOpWrite() -
clearOpWrite
protected final void clearOpWrite()
-