Class NioConnection
java.lang.Object
org.jgroups.blocks.cs.Connection
org.jgroups.blocks.cs.NioConnection
- All Implemented Interfaces:
Closeable, AutoCloseable
An NIO based impl of
Connection- Since:
- 3.6.5
- Author:
- Bela Ban
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classReads a peer address from a SocketChannel. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SocketChannelprotected ByteBufferprotected booleanprotected ByteBufferprotected SelectionKeyprotected ByteBufferprotected final MessageReaderprotected intprotected intprotected final NioConnection.PeerAddressReaderprotected final BuffersFields inherited from class Connection
closed_gracefully, cookie, GRACEFUL_CLOSE, last_access, peer_addr, send_lock, server -
Constructor Summary
ConstructorsConstructorDescriptionNioConnection(SocketChannel channel, NioBaseServer server) NioConnection(Address peer_addr, NioBaseServer server) Creates a connection stub and binds it, useconnect(Address)to connect -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_read()protected voidaddBuffer(ByteBuffer buf) protected voidaddBuffers(ByteBuffer[] bufs) voidclearSelectionKey(int interest_ops) voidclose()voidclose(boolean graceful) voidprotected voidbooleancopyOnPartialWrite(boolean b) protected ByteBuffercreateBuffer(int size) protected voidprotected voiddoClose()voidflush()booleanisClosed()booleanbooleankey()key(SelectionKey k) intnumDrops()intvoidread()Read the length first, then the actual data.voidregisterSelectionKey(int interest_ops) reset()voidsend(byte[] buf, int offset, int length) protected voidSends the buffers currently present in send_bufvoidsend(ByteBuffer buf) Sends a message.voidsend(ByteBuffer[] bufs) protected voidsendLocalAddress(Address local_addr) protected voidsetSocketParameters(Socket client_sock) voidstart()status()toString()Methods inherited from class Connection
getTimestamp, isClosedGracefully, isExpired, peerAddress, setClosedGracefully, updateLastAccessed
-
Field Details
-
channel
-
key
-
send_buf
-
message_reader
-
copy_on_partial_write
protected boolean copy_on_partial_write -
partial_writes
protected int partial_writes -
num_drops
protected int num_drops -
peer_addr_reader
-
length_buf
-
graceful_close_buf
-
cookie_buffer
-
-
Constructor Details
-
NioConnection
Creates a connection stub and binds it, useconnect(Address)to connect- Throws:
Exception
-
NioConnection
- Throws:
Exception
-
-
Method Details
-
isConnected
public boolean isConnected()- Specified by:
isConnectedin classConnection
-
isConnectionPending
public boolean isConnectionPending()- Specified by:
isConnectionPendingin classConnection
-
isClosed
public boolean isClosed()- Specified by:
isClosedin classConnection
-
localAddress
- Specified by:
localAddressin classConnection
-
key
-
key
-
copyOnPartialWrite
-
copyOnPartialWrite
public boolean copyOnPartialWrite() -
numPartialWrites
public int numPartialWrites() -
numDrops
public int numDrops() -
reset
-
registerSelectionKey
public void registerSelectionKey(int interest_ops) -
clearSelectionKey
public void clearSelectionKey(int interest_ops) -
connect
- Specified by:
connectin classConnection- Throws:
Exception
-
connect
-
start
- Specified by:
startin classConnection- Throws:
Exception
-
send
- Specified by:
sendin classConnection- Throws:
Exception
-
send
Sends a message. If the previous write didn't complete, tries to complete it. If this still doesn't complete, the message is dropped (needs to be retransmitted, e.g. by UNICAST3 or NAKACK2).- Specified by:
sendin classConnection- Throws:
Exception
-
send
- Specified by:
sendin classConnection- Throws:
Exception
-
read
-
close
- Throws:
IOException
-
close
- Specified by:
closein classConnection- Throws:
IOException
-
flush
public void flush()- Specified by:
flushin classConnection
-
toString
-
status
- Specified by:
statusin classConnection
-
_read
-
send
-
addBuffer
-
addBuffers
-
doClose
protected void doClose() -
setSocketParameters
- Throws:
SocketException
-
sendLocalAddress
-
createBuffers
protected void createBuffers() -
createBuffer
-