Package org.jgroups.blocks.cs
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SocketChannelprotected booleanprotected SelectionKeyprotected final ByteBufferprotected intprotected Buffersprotected final Buffersprotected final LockFields inherited from class org.jgroups.blocks.cs.Connection
cookie, last_access, peer_addr, 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()voidclearSelectionKey(int interest_ops) voidclose()voidprotected voidbooleancopyOnPartialWrite(boolean b) voidflush()protected static byte[]getBuffer(ByteBuffer buf) booleanisClosed()booleanbooleankey()key(SelectionKey k) protected ByteBuffermakeLengthBuffer(int length) intvoidread()Read the length first, then the actual data.protected AddressvoidregisterSelectionKey(int interest_ops) voidsend()voidsend(byte[] buf, int offset, int length) voidsend(ByteBuffer buf) Sends a message.protected voidsend(ByteBuffer buf, boolean send_length) protected voidsendLocalAddress(Address local_addr) protected voidsetSocketParameters(Socket client_sock) voidstart()status()toString()Methods inherited from class org.jgroups.blocks.cs.Connection
getTimestamp, isExpired, peerAddress, updateLastAccessed
-
Field Details
-
channel
-
key
-
send_buf
-
length_buf
-
copy_on_partial_write
protected boolean copy_on_partial_write -
partial_writes
protected int partial_writes -
send_lock
-
recv_buf
-
-
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() -
registerSelectionKey
public void registerSelectionKey(int interest_ops) -
clearSelectionKey
public void clearSelectionKey(int interest_ops) -
connect
- Specified by:
connectin classConnection- Throws:
Exception
-
connect
- Throws:
Exception
-
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- Parameters:
buf-- Throws:
Exception
-
send
- Throws:
Exception
-
send
- Throws:
Exception
-
read
Read the length first, then the actual data. This method is not reentrant and access must be synchronized- Throws:
Exception
-
_read
- Throws:
Exception
-
close
- Throws:
IOException
-
flush
public void flush()- Specified by:
flushin classConnection
-
toString
-
status
- Specified by:
statusin classConnection
-
setSocketParameters
- Throws:
SocketException
-
sendLocalAddress
- Throws:
Exception
-
readPeerAddress
- Throws:
Exception
-
getBuffer
-
makeLengthBuffer
-