Class AbstractNioChannel<C extends java.nio.channels.SelectableChannel & java.nio.channels.WritableByteChannel>
- java.lang.Object
-
- org.jboss.netty.channel.AbstractChannel
-
- org.jboss.netty.channel.socket.nio.AbstractNioChannel<C>
-
- Direct Known Subclasses:
NioDatagramChannel
,NioSocketChannel
abstract class AbstractNioChannel<C extends java.nio.channels.SelectableChannel & java.nio.channels.WritableByteChannel> extends AbstractChannel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
AbstractNioChannel.WriteRequestQueue
private class
AbstractNioChannel.WriteTask
-
Field Summary
Fields Modifier and Type Field Description (package private) C
channel
(package private) SocketSendBufferPool.SendBuffer
currentWriteBuffer
(package private) MessageEvent
currentWriteEvent
The current writeMessageEvent
(package private) java.util.concurrent.atomic.AtomicInteger
highWaterMarkCounter
Keeps track of the highWaterMark.(package private) boolean
inWriteNowLoop
Boolean that indicates that write operation is in progress.private java.net.InetSocketAddress
localAddress
(package private) java.net.InetSocketAddress
remoteAddress
(package private) AbstractNioWorker
worker
TheAbstractNioWorker
.(package private) AbstractNioChannel.WriteRequestQueue
writeBufferQueue
Queue of writeMessageEvent
s.(package private) java.util.concurrent.atomic.AtomicInteger
writeBufferSize
Keeps track of the number of bytes that theAbstractNioChannel.WriteRequestQueue
currently contains.(package private) java.lang.Object
writeLock
Monitor object for synchronizing access to theAbstractNioChannel.WriteRequestQueue
.(package private) boolean
writeSuspended
(package private) java.lang.Runnable
writeTask
WriteTask that performs write operations.(package private) java.util.concurrent.atomic.AtomicBoolean
writeTaskInTaskQueue
Indicates if there is aAbstractNioChannel.WriteTask
in the task queue.-
Fields inherited from interface org.jboss.netty.channel.Channel
OP_NONE, OP_READ, OP_READ_WRITE, OP_WRITE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNioChannel(java.lang.Integer id, Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, AbstractNioWorker worker, C ch)
protected
AbstractNioChannel(Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, AbstractNioWorker worker, C ch)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract NioChannelConfig
getConfig()
Returns the configuration of this channel.protected int
getInternalInterestOps()
java.net.InetSocketAddress
getLocalAddress()
Returns the local address where this channel is bound to.(package private) abstract java.net.InetSocketAddress
getLocalSocketAddress()
java.net.InetSocketAddress
getRemoteAddress()
Returns the remote address where this channel is connected to.(package private) abstract java.net.InetSocketAddress
getRemoteSocketAddress()
AbstractNioWorker
getWorker()
Return theAbstractNioWorker
that handle the IO of theAbstractNioChannel
protected boolean
setClosed()
Marks this channel as closed.protected void
setInternalInterestOps(int interestOps)
Sets theinterestOps
property of this channel immediately.-
Methods inherited from class org.jboss.netty.channel.AbstractChannel
bind, close, compareTo, connect, disconnect, equals, getAttachment, getCloseFuture, getFactory, getId, getInterestOps, getParent, getPipeline, getSucceededFuture, getUnsupportedOperationFuture, getUserDefinedWritability, hashCode, isOpen, isReadable, isWritable, setAttachment, setInterestOps, setReadable, setUnwritable, setUserDefinedWritability, setWritable, toString, unbind, write, write
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jboss.netty.channel.Channel
isBound, isConnected
-
-
-
-
Field Detail
-
worker
final AbstractNioWorker worker
TheAbstractNioWorker
.
-
writeLock
final java.lang.Object writeLock
Monitor object for synchronizing access to theAbstractNioChannel.WriteRequestQueue
.
-
writeTask
final java.lang.Runnable writeTask
WriteTask that performs write operations.
-
writeTaskInTaskQueue
final java.util.concurrent.atomic.AtomicBoolean writeTaskInTaskQueue
Indicates if there is aAbstractNioChannel.WriteTask
in the task queue.
-
writeBufferQueue
final AbstractNioChannel.WriteRequestQueue writeBufferQueue
Queue of writeMessageEvent
s.
-
writeBufferSize
final java.util.concurrent.atomic.AtomicInteger writeBufferSize
Keeps track of the number of bytes that theAbstractNioChannel.WriteRequestQueue
currently contains.
-
highWaterMarkCounter
final java.util.concurrent.atomic.AtomicInteger highWaterMarkCounter
Keeps track of the highWaterMark.
-
currentWriteEvent
MessageEvent currentWriteEvent
The current writeMessageEvent
-
currentWriteBuffer
SocketSendBufferPool.SendBuffer currentWriteBuffer
-
inWriteNowLoop
boolean inWriteNowLoop
Boolean that indicates that write operation is in progress.
-
writeSuspended
boolean writeSuspended
-
localAddress
private volatile java.net.InetSocketAddress localAddress
-
remoteAddress
volatile java.net.InetSocketAddress remoteAddress
-
channel
final C extends java.nio.channels.SelectableChannel & java.nio.channels.WritableByteChannel channel
-
-
Constructor Detail
-
AbstractNioChannel
protected AbstractNioChannel(java.lang.Integer id, Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, AbstractNioWorker worker, C ch)
-
AbstractNioChannel
protected AbstractNioChannel(Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, AbstractNioWorker worker, C ch)
-
-
Method Detail
-
getWorker
public AbstractNioWorker getWorker()
Return theAbstractNioWorker
that handle the IO of theAbstractNioChannel
- Returns:
- worker
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()
Description copied from interface:Channel
Returns the local address where this channel is bound to. The returnedSocketAddress
is supposed to be down-cast into more concrete type such asInetSocketAddress
to retrieve the detailed information.- Returns:
- the local address of this channel.
null
if this channel is not bound.
-
getRemoteAddress
public java.net.InetSocketAddress getRemoteAddress()
Description copied from interface:Channel
Returns the remote address where this channel is connected to. The returnedSocketAddress
is supposed to be down-cast into more concrete type such asInetSocketAddress
to retrieve the detailed information.- Returns:
- the remote address of this channel.
null
if this channel is not connected. If this channel is not connected but it can receive messages from arbitrary remote addresses (e.g.DatagramChannel
, useMessageEvent.getRemoteAddress()
to determine the origination of the received message as this method will returnnull
.
-
getConfig
public abstract NioChannelConfig getConfig()
Description copied from interface:Channel
Returns the configuration of this channel.
-
getInternalInterestOps
protected int getInternalInterestOps()
- Overrides:
getInternalInterestOps
in classAbstractChannel
-
setInternalInterestOps
protected void setInternalInterestOps(int interestOps)
Description copied from class:AbstractChannel
Sets theinterestOps
property of this channel immediately. This method is intended to be called by an internal component - please do not call it unless you know what you are doing.- Overrides:
setInternalInterestOps
in classAbstractChannel
-
setClosed
protected boolean setClosed()
Description copied from class:AbstractChannel
Marks this channel as closed. This method is intended to be called by an internal component - please do not call it unless you know what you are doing.- Overrides:
setClosed
in classAbstractChannel
- Returns:
true
if and only if this channel was not marked as closed yet
-
getLocalSocketAddress
abstract java.net.InetSocketAddress getLocalSocketAddress() throws java.lang.Exception
- Throws:
java.lang.Exception
-
getRemoteSocketAddress
abstract java.net.InetSocketAddress getRemoteSocketAddress() throws java.lang.Exception
- Throws:
java.lang.Exception
-
-