Package io.netty.channel.nio
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,java.lang.Comparable<Channel>
- Direct Known Subclasses:
NioDomainSocketChannel,NioSocketChannel,NioUdtByteConnectorChannel
public abstract class AbstractNioByteChannel extends AbstractNioChannel
AbstractNioChannelbase class forChannels that operate on bytes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractNioByteChannel.NioByteUnsafe-
Nested classes/interfaces inherited from class io.netty.channel.nio.AbstractNioChannel
AbstractNioChannel.AbstractNioUnsafe, AbstractNioChannel.NioUnsafe
-
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 inherited from class io.netty.channel.nio.AbstractNioChannel
readInterestOp, readOps
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractNioByteChannel(Channel parent, java.nio.channels.SelectableChannel ch)Create a new instance
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidclearOpWrite()protected abstract intdoReadBytes(ByteBuf buf)Read bytes into the givenByteBufand return the amount.protected voiddoWrite(ChannelOutboundBuffer in)Flush the content of the given buffer to the remote peer.protected intdoWrite0(ChannelOutboundBuffer in)Write objects to the OS.protected abstract intdoWriteBytes(ByteBuf buf)Write bytes form the givenByteBufto the underlyingChannel.protected abstract longdoWriteFileRegion(FileRegion region)Write aFileRegionprotected java.lang.ObjectfilterOutboundMessage(java.lang.Object msg)Invoked when a new message is added to aChannelOutboundBufferof thisAbstractChannel, so that theChannelimplementation converts the message to another.protected voidincompleteWrite(boolean setOpWrite)protected booleanisInputShutdown0()ChannelMetadatametadata()protected AbstractNioChannel.AbstractNioUnsafenewUnsafe()Create a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannelprotected voidsetOpWrite()protected abstract ChannelFutureshutdownInput()Shutdown the input side of the channel.-
Methods inherited from class io.netty.channel.nio.AbstractNioChannel
addAndSubmit, clearReadPending, doBeginRead, doClose, doConnect, doDeregister, doFinishConnect, doRegister, isCompatible, isOpen, isReadPending, javaChannel, newDirectBuffer, newDirectBuffer, registration, removeAndSubmit, selectionKey, setReadPending, unsafe
-
Methods inherited from class io.netty.channel.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, voidPromise
-
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, 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, writeAndFlush
-
-
-
-
Method Detail
-
shutdownInput
protected abstract ChannelFuture shutdownInput()
Shutdown the input side of the channel.
-
isInputShutdown0
protected boolean isInputShutdown0()
-
newUnsafe
protected AbstractNioChannel.AbstractNioUnsafe newUnsafe()
Description copied from class:AbstractChannelCreate a newAbstractChannel.AbstractUnsafeinstance which will be used for the life-time of theChannel- Specified by:
newUnsafein classAbstractChannel
-
metadata
public ChannelMetadata metadata()
Description copied from interface:Channel
-
doWrite0
protected final int doWrite0(ChannelOutboundBuffer in) throws java.lang.Exception
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:
java.lang.Exception- if an I/O exception occurs during write.
-
doWrite
protected void doWrite(ChannelOutboundBuffer in) throws java.lang.Exception
Description copied from class:AbstractChannelFlush the content of the given buffer to the remote peer.- Specified by:
doWritein classAbstractChannel- Throws:
java.lang.Exception
-
filterOutboundMessage
protected final java.lang.Object filterOutboundMessage(java.lang.Object msg)
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
protected abstract long doWriteFileRegion(FileRegion region) throws java.lang.Exception
Write aFileRegion- Parameters:
region- theFileRegionfrom which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
java.lang.Exception
-
doReadBytes
protected abstract int doReadBytes(ByteBuf buf) throws java.lang.Exception
Read bytes into the givenByteBufand return the amount.- Throws:
java.lang.Exception
-
doWriteBytes
protected abstract int doWriteBytes(ByteBuf buf) throws java.lang.Exception
Write bytes form the givenByteBufto the underlyingChannel.- Parameters:
buf- theByteBuffrom which the bytes should be written- Returns:
- amount the amount of written bytes
- Throws:
java.lang.Exception
-
setOpWrite
protected final void setOpWrite()
-
clearOpWrite
protected final void clearOpWrite()
-
-