Package org.jppf.nio
Class AbstractNioContext
java.lang.Object
org.jppf.nio.AbstractNioContext
- All Implemented Interfaces:
CloseableContext,NioChannelHandler,NioContext
- Direct Known Subclasses:
AcceptorContext
Context associated with an open communication channel.
- Author:
- Laurent Cohen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanWhether this context has been closed.protected StringUnique ID for the corresponding connection on the remote peer.protected booleanWhether this context is enabled.protected JPPFSnapshotInbound traffic statistics snapshot.protected booleanWhether this is a local channel.protected RunnableAn optional action to perform upon closing this context or its associated channel.protected JPPFSnapshotOutbound traffic statistics snapshot.protected booleanDetermines whether the associated channel is connected to a peer server.longThe number of bytes read by this channel.protected NioMessageContainer for the current message data.protected SocketChannelThe associated socket channel.protected booleanDetermines whether the connection was opened on an SSL port.protected SSLHandlerThe SSL engine associated with the channel.protected StringUuid of the remote client or node.longThe number of bytes written by this channel.protected NioMessageThe message to write, if any. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the unique ID for the corresponding connection on the remote peer.intGet the container for the current message data.Get the associated socket chanel, if any.Get the SSL engine manager associated with the channel.getUuid()Get the uuid of the node or client for this context.booleanisClosed()Determine whether this channel has been closed.booleanWhether this context is enabled.booleanisLocal()booleanisPeer()Determine whether the associated channel is connected to a peer server.booleanisSecure()Determine whether the associated channel is secured via SSL/TLS.booleanisSsl()Determines whether the connection was opened on an SSL port.protected NioMessageGet the next messge to send, if any.protected voidonClose()Callback that can be invoked upon closing this context or its associated channel.voidsetClosed(boolean closed) Specify whether this channel has been closed.voidsetConnectionUuid(String connectionUuid) Set the unique ID for the corresponding connection on the remote peer.voidsetEnabled(boolean enabled) Enable or disable this context.voidsetInterestOps(int interestOps) Set the socket channel's interest ops.voidsetLocal(boolean local) voidsetOnCloseAction(Runnable onCloseAction) Set an optional action to perform upon closing this context or its associated channel.voidsetPeer(boolean peer) Specify whether the associated channel is connected to a peer server.voidsetReadMessage(NioMessage message) Set the container for the current message data.voidsetSelectionKey(SelectionKey selectionKey) Set the associated selection key.voidsetSsl(boolean ssl) Specifies whether the connection was opened on an SSL port.voidsetSSLHandler(SSLHandler sslHandler) Get the SSL engine associated with the channel.voidSet the uuid of the node or client for this context.voidsetWriteMessage(NioMessage writeMessage) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jppf.nio.NioContext
handleException, readMessage, writeMessage
-
Field Details
-
uuid
Uuid of the remote client or node. -
readMessage
Container for the current message data. -
writeMessage
The message to write, if any. -
connectionUuid
Unique ID for the corresponding connection on the remote peer. -
sslHandler
The SSL engine associated with the channel. -
peer
protected boolean peerDetermines whether the associated channel is connected to a peer server. -
ssl
protected boolean sslDetermines whether the connection was opened on an SSL port. -
enabled
protected boolean enabledWhether this context is enabled. -
closed
Whether this context has been closed. -
onCloseAction
An optional action to perform upon closing this context or its associated channel. -
readByteCount
public long readByteCountThe number of bytes read by this channel. -
writeByteCount
public long writeByteCountThe number of bytes written by this channel. -
socketChannel
The associated socket channel. -
inSnapshot
Inbound traffic statistics snapshot. -
outSnapshot
Outbound traffic statistics snapshot. -
local
protected boolean localWhether this is a local channel.
-
-
Constructor Details
-
AbstractNioContext
public AbstractNioContext()
-
-
Method Details
-
getUuid
Description copied from interface:NioContextGet the uuid of the node or client for this context.- Specified by:
getUuidin interfaceNioContext- Returns:
- the uuid as a string.
-
setUuid
Description copied from interface:NioContextSet the uuid of the node or client for this context.- Specified by:
setUuidin interfaceNioContext- Parameters:
uuid- the uuid as a string.
-
getReadMessage
Get the container for the current message data.- Returns:
- an
NioMessageinstance.
-
setReadMessage
Set the container for the current message data.- Parameters:
message- anNioMessageinstance.
-
getWriteMessage
- Returns:
- the message to write, if any.
-
setWriteMessage
- Parameters:
writeMessage- the message to write, if any.
-
nextMessageToSend
Get the next messge to send, if any.- Returns:
- the next message in the send queue, or
nullif the queue is empty.
-
getConnectionUuid
Get the unique ID for the corresponding connection on the remote peer.- Returns:
- the id as a string.
-
setConnectionUuid
Set the unique ID for the corresponding connection on the remote peer.- Parameters:
connectionUuid- the id as a string.
-
getSSLHandler
Description copied from interface:NioContextGet the SSL engine manager associated with the channel.- Specified by:
getSSLHandlerin interfaceNioContext- Returns:
- an instance of
SSLHandlerImpl.
-
setSSLHandler
Description copied from interface:NioContextGet the SSL engine associated with the channel.- Specified by:
setSSLHandlerin interfaceNioContext- Parameters:
sslHandler- an instance ofSSLHandlerImpl.
-
isPeer
public boolean isPeer()Description copied from interface:NioContextDetermine whether the associated channel is connected to a peer server.- Specified by:
isPeerin interfaceNioContext- Returns:
trueif the channel is connected to a peer server,falseotherwise.
-
setPeer
public void setPeer(boolean peer) Description copied from interface:NioContextSpecify whether the associated channel is connected to a peer server.- Specified by:
setPeerin interfaceNioContext- Parameters:
peer-trueif the channel is connected to a peer server,falseotherwise.
-
toString
-
isSecure
public boolean isSecure()Determine whether the associated channel is secured via SSL/TLS.- Returns:
trueif the channel is secure,falseotherwise.
-
isSsl
public boolean isSsl()Determines whether the connection was opened on an SSL port.- Specified by:
isSslin interfaceNioContext- Returns:
truefor an SSL connection,falseotherwise.
-
setSsl
public void setSsl(boolean ssl) Specifies whether the connection was opened on an SSL port.- Specified by:
setSslin interfaceNioContext- Parameters:
ssl-truefor an SSL connection,falseotherwise.
-
isEnabled
public boolean isEnabled()Description copied from interface:NioContextWhether this context is enabled.- Specified by:
isEnabledin interfaceNioContext- Returns:
trueif this context is enabled,falseotherwise.
-
setEnabled
public void setEnabled(boolean enabled) Description copied from interface:NioContextEnable or disable this context.- Specified by:
setEnabledin interfaceNioContext- Parameters:
enabled-trueto enable this context,falseto disable it.
-
isClosed
public boolean isClosed()Description copied from interface:CloseableContextDetermine whether this channel has been closed.- Specified by:
isClosedin interfaceCloseableContext- Returns:
trueif this channel has been closed,falseotherwise.
-
setClosed
public void setClosed(boolean closed) Description copied from interface:CloseableContextSpecify whether this channel has been closed.- Specified by:
setClosedin interfaceCloseableContext- Parameters:
closed-trueif this channel has been closed,falseotherwise.
-
setOnCloseAction
Set an optional action to perform upon closing this context or its associated channel.- Parameters:
onCloseAction- aRunnableinstance.
-
onClose
protected void onClose()Callback that can be invoked upon closing this context or its associated channel. -
getSocketChannel
Description copied from interface:NioContextGet the associated socket chanel, if any.- Specified by:
getSocketChannelin interfaceNioContext- Returns:
- the associated socket channel.
-
getInterestOps
public int getInterestOps()- Specified by:
getInterestOpsin interfaceNioChannelHandler- Returns:
- the socket channel's interest ops.
-
setInterestOps
public void setInterestOps(int interestOps) Description copied from interface:NioChannelHandlerSet the socket channel's interest ops.- Specified by:
setInterestOpsin interfaceNioChannelHandler- Parameters:
interestOps- the interest ops to set.
-
getSelectionKey
- Specified by:
getSelectionKeyin interfaceNioChannelHandler- Returns:
- the associated selection key.
-
setSelectionKey
Description copied from interface:NioChannelHandlerSet the associated selection key.- Specified by:
setSelectionKeyin interfaceNioChannelHandler- Parameters:
selectionKey- the key to set.
-
isLocal
public boolean isLocal()- Returns:
- whether this is a local channel.
-
setLocal
public void setLocal(boolean local) - Parameters:
local- whether this is a local channel.
-