|
barchart-udt-core 2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.barchart.udt.SocketUDT
public class SocketUDT
UDT native socket wrapper
note: current implementation supports IPv4 only (no IPv6)
| Field Summary | |
|---|---|
static int |
DEFAULT_ACCEPT_QUEUE_SIZE
Maximum number of connections queued in listening mode by accept() |
static int |
DEFAULT_FILE_BLOCK_SIZE
Block size used by sendFile(File, long, long) |
static int |
DEFAULT_MAX_SELECTOR_SIZE
Maximum number sockets that can participate in a SelectorUDT.select() operation; see epoll.h
to confirm current limit |
static int |
DEFAULT_MIN_SELECTOR_TIMEOUT
Minimum timeout of a SelectorUDT.select()
operations. |
static int |
INFINITE_TTL
infinite message time to live; |
static boolean |
INIT_OK
Helper value that can be checked from CCC class and force JNI library load |
protected static org.slf4j.Logger |
log
|
static int |
SIGNATURE_JNI
JNI Signature that must match between java code and c++ code on all platforms; failure to match will abort native library load, as an indication of inconsistent build. |
static int |
TIMEOUT_INFINITE
infinite timeout: |
static long |
TIMEOUT_NONE
zero timeout: |
static int |
UDT_EXCEPT_INDEX
UDT::select() sizeArray/sizeBuffer index offset for EXCEPTION report |
static int |
UDT_READ_INDEX
UDT::select() sizeArray/sizeBuffer index offset for READ interest |
static int |
UDT_SIZE_COUNT
UDT::select() sizeArray/sizeBuffer size count or number of arrays/buffers |
static int |
UDT_WRITE_INDEX
UDT::select() sizeArray/sizeBuffer index offset for WRITE interest |
| Constructor Summary | |
|---|---|
|
SocketUDT(TypeUDT type)
"Primary" socket. |
protected |
SocketUDT(TypeUDT type,
int socketID)
"Secondary" socket. |
| Method Summary | ||
|---|---|---|
SocketUDT |
accept()
|
|
protected SocketUDT |
accept0()
|
|
void |
bind(InetSocketAddress localSocketAddress)
|
|
protected void |
bind0(InetSocketAddress localSocketAddress)
|
|
static void |
cleanup()
Cleans up global JNI references and the UDT library. |
|
void |
clearError()
Clear error status on a socket, if any. |
|
protected void |
clearError0()
|
|
void |
close()
Close socket if not already closed. |
|
protected void |
close0()
|
|
void |
connect(InetSocketAddress remoteSocketAddress)
Connect to remote UDT socket. |
|
protected void |
connect0(InetSocketAddress remoteSocketAddress)
|
|
protected static void |
epollAdd0(int epollID,
int socketID,
int epollOpt)
|
|
protected static int |
epollCreate0()
|
|
protected static void |
epollRelease0(int epollID)
|
|
protected static void |
epollRemove0(int epollID,
int socketID)
|
|
protected static void |
epollUpdate0(int epollID,
int socketID,
int epollMask)
update epoll mask |
|
protected static int |
epollVerify0(int epollID,
int socketID)
query epoll mask |
|
protected static int |
epollWait0(int epollID,
IntBuffer readBuffer,
IntBuffer writeBuffer,
IntBuffer sizeBuffer,
long millisTimeout)
|
|
boolean |
equals(Object otherSocketUDT)
Note: equality is based on socketID. |
|
protected void |
finalize()
NOTE: catch all exceptions; else prevents GC |
|
ErrorUDT |
getError()
Error object wrapper. |
|
int |
getErrorCode()
Error code set by last operation on a socket. |
|
protected int |
getErrorCode0()
|
|
String |
getErrorMessage()
Native error message set by last operation on a socket. |
|
protected String |
getErrorMessage0()
|
|
int |
getListenQueueSize()
|
|
InetAddress |
getLocalInetAddress()
|
|
int |
getLocalInetPort()
|
|
InetSocketAddress |
getLocalSocketAddress()
|
|
boolean |
getMessageIsOdered()
default isOrdered value used by sendmsg mode |
|
int |
getMessageTimeTolLive()
default timeToLive value used by sendmsg mode |
|
|
getOption(OptionUDT<T> option)
|
|
protected Object |
getOption0(int code,
Class<?> klaz)
|
|
int |
getReceiveBufferSize()
Get maximum receive buffer size. |
|
InetAddress |
getRemoteInetAddress()
|
|
int |
getRemoteInetPort()
|
|
InetSocketAddress |
getRemoteSocketAddress()
|
|
boolean |
getReuseAddress()
Check if local bind address is set to reuse mode. |
|
int |
getSendBufferSize()
Get maximum send buffer size. |
|
protected static int |
getSignatureJNI0()
Verify that java code and c++ code builds are consistent. |
|
int |
getSoLinger()
Get time to linger on close (seconds). |
|
int |
getSoTimeout()
Get "any blocking operation" timeout setting. |
|
protected int |
getStatus0()
|
|
int |
hashCode()
Note: uses socketID as hash code. |
|
protected boolean |
hasLoadedLocalSocketAddress()
Load localSocketAddress value. |
|
protected boolean |
hasLoadedRemoteSocketAddress()
Load remoteSocketAddress value. |
|
int |
id()
native socket descriptor id; assigned by udt library |
|
protected static void |
initClass0()
Call this after loading native library. |
|
protected int |
initInstance0(int typeCode)
used by default constructor |
|
protected int |
initInstance1(int socketUDT)
used by accept() internally |
|
boolean |
isBlocking()
Check if socket is in strict blocking mode. |
|
boolean |
isBound()
Check if socket is bound. |
|
boolean |
isClosed()
Check if socket is closed. |
|
boolean |
isConnected()
Check if KindUDT.CONNECTOR socket is connected. |
|
boolean |
isNonBlocking()
Check if socket is in strict non-blocking mode. |
|
boolean |
isOpen()
Check if socket is open. |
|
boolean |
isRendezvous()
|
|
void |
listen(int queueSize)
|
|
protected void |
listen0(int queueSize)
|
|
MonitorUDT |
monitor()
performance monitor; updated by updateMonitor(boolean) in JNI |
|
int |
receive(byte[] array)
receive into byte[] array upto array.length bytes |
|
int |
receive(byte[] array,
int position,
int limit)
receive into byte[] array upto size=limit-position bytes |
|
int |
receive(ByteBuffer buffer)
receive into DirectByteBuffer; upto
Buffer.remaining() bytes |
|
protected static int |
receive0(int socketID,
int socketType,
byte[] array)
receive into a complete byte array |
|
protected static int |
receive1(int socketID,
int socketType,
byte[] array,
int position,
int limit)
receive into a portion of a byte array |
|
protected static int |
receive2(int socketID,
int socketType,
ByteBuffer buffer,
int position,
int limit)
receive into a DirectByteBuffer |
|
long |
receiveFile(File file,
long offset,
long length)
Receive file from remote peer. |
|
protected static long |
receiveFile0(int socketID,
String path,
long offset,
long length,
int block)
Receive file. |
|
static int |
selectEpoll(int epollId,
IntBuffer readBuffer,
IntBuffer writeBuffer,
IntBuffer sizeBuffer,
long millisTimeout)
Basic access to UDT socket readiness selection feature. |
|
int |
send(byte[] array)
send from byte[] array upto size=array.length bytes |
|
int |
send(byte[] array,
int position,
int limit)
send from byte[] array upto size=limit-position bytes |
|
int |
send(ByteBuffer buffer)
send from DirectByteBuffer, upto
Buffer.remaining() bytes |
|
protected static int |
send0(int socketID,
int socketType,
int timeToLive,
boolean isOrdered,
byte[] array)
send from a complete byte[] array; wrapper for UDT::send(), UDT::sendmsg() |
|
protected static int |
send1(int socketID,
int socketType,
int timeToLive,
boolean isOrdered,
byte[] array,
int arayPosition,
int arrayLimit)
send from a portion of a byte[] array; wrapper for UDT::send(), UDT::sendmsg() |
|
protected static int |
send2(int socketID,
int socketType,
int timeToLive,
boolean isOrdered,
ByteBuffer buffer,
int bufferPosition,
int bufferLimit)
send from DirectByteBuffer;
wrapper for UDT::send(), UDT::sendmsg() |
|
long |
sendFile(File file,
long offset,
long length)
Send file to remote peer. |
|
protected static long |
sendFile0(int socketID,
String path,
long offset,
long length,
int block)
Send file. |
|
void |
setBlocking(boolean block)
Configure socket in strict blocking / strict non-blocking mode. |
|
void |
setDefaultMessageSendMode()
Apply default settings for message mode. |
|
void |
setMessageIsOdered(boolean isOrdered)
default isOrdered value used by sendmsg mode |
|
void |
setMessageTimeTolLive(int timeToLive)
default timeToLive value used by sendmsg mode |
|
|
setOption(OptionUDT<T> option,
T value)
|
|
protected void |
setOption0(int code,
Class<?> klaz,
Object value)
|
|
void |
setReceiveBufferSize(int size)
Set maximum receive buffer size. |
|
void |
setRendezvous(boolean isOn)
|
|
void |
setReuseAddress(boolean on)
|
|
void |
setSendBufferSize(int size)
Set maximum send buffer size. |
|
void |
setSoLinger(boolean on,
int linger)
|
|
void |
setSoTimeout(int millisTimeout)
call timeout (milliseconds); Set a timeout on blocking Socket operations: ServerSocket.accept(); SocketInputStream.read(); DatagramSocket.receive(); Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds. |
|
StatusUDT |
status()
returns native status of underlying native UDT socket |
|
protected static void |
stopClass0()
Call this before unloading native library. |
|
protected static void |
testCrashJVM0()
|
|
protected static void |
testDirectByteBufferAccess0(ByteBuffer buffer)
|
|
protected static void |
testDirectIntBufferAccess0(IntBuffer buffer)
|
|
protected static void |
testDirectIntBufferLoad0(IntBuffer buffer)
|
|
protected static void |
testEmptyCall0()
|
|
protected static void |
testFillArray0(byte[] array)
|
|
protected static void |
testFillBuffer0(ByteBuffer buffer)
|
|
protected static void |
testGetSetArray0(int[] array,
boolean isReturn)
|
|
protected static void |
testInvalidClose0(int socketID)
|
|
protected static void |
testIterateArray0(Object[] array)
|
|
protected static void |
testIterateSet0(Set<Object> set)
|
|
protected static int[] |
testMakeArray0(int size)
|
|
String |
toString()
|
|
String |
toStringMonitor()
Show current monitor status. |
|
String |
toStringOptions()
Show current socket options. |
|
TypeUDT |
type()
message/stream socket type; read by JNI |
|
void |
updateMonitor(boolean makeClear)
Load updated statistics values into monitor object. |
|
protected void |
updateMonitor0(boolean makeClear)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_ACCEPT_QUEUE_SIZE
accept()
public static final int DEFAULT_FILE_BLOCK_SIZE
sendFile(File, long, long)
public static final int DEFAULT_MAX_SELECTOR_SIZE
SelectorUDT.select() operation; see epoll.h
to confirm current limit
public static final int DEFAULT_MIN_SELECTOR_TIMEOUT
SelectorUDT.select()
operations.
public static final int INFINITE_TTL
@Native public static boolean INIT_OK
protected static final org.slf4j.Logger log
@Native public static final int SIGNATURE_JNI
public static final int TIMEOUT_INFINITE
blocking send/receive
epoll wait
public static long TIMEOUT_NONE
epoll wait
@Native public static final int UDT_EXCEPT_INDEX
@Native public static final int UDT_READ_INDEX
@Native public static final int UDT_SIZE_COUNT
@Native public static final int UDT_WRITE_INDEX
| Constructor Detail |
|---|
public SocketUDT(TypeUDT type)
throws ExceptionUDT
setDefaultMessageSendMode()
type - UDT socket type
ExceptionUDT
protected SocketUDT(TypeUDT type,
int socketID)
throws ExceptionUDT
accept0(), will apply
setDefaultMessageSendMode()
socketID - UDT socket descriptor;
ExceptionUDT| Method Detail |
|---|
public static void cleanup()
throws ExceptionUDT
The behavior of SocketUDT class after a call to cleanup is undefined, so it should only ever be called once you are done and you are ready for the class loader to unload the JNI library
ExceptionUDT
protected static void epollAdd0(int epollID,
int socketID,
int epollOpt)
throws ExceptionUDT
ExceptionUDT
protected static int epollCreate0()
throws ExceptionUDT
ExceptionUDT
protected static void epollRelease0(int epollID)
throws ExceptionUDT
ExceptionUDT
protected static void epollRemove0(int epollID,
int socketID)
throws ExceptionUDT
ExceptionUDT
protected static void epollUpdate0(int epollID,
int socketID,
int epollMask)
throws ExceptionUDT
ExceptionUDT
protected static int epollVerify0(int epollID,
int socketID)
throws ExceptionUDT
ExceptionUDT
protected static int epollWait0(int epollID,
IntBuffer readBuffer,
IntBuffer writeBuffer,
IntBuffer sizeBuffer,
long millisTimeout)
throws ExceptionUDT
ExceptionUDTprotected static int getSignatureJNI0()
SIGNATURE_JNI
protected static void initClass0()
throws ExceptionUDT
ExceptionUDT
protected static int receive0(int socketID,
int socketType,
byte[] array)
throws ExceptionUDT
ExceptionUDT
protected static int receive1(int socketID,
int socketType,
byte[] array,
int position,
int limit)
throws ExceptionUDT
ExceptionUDT
protected static int receive2(int socketID,
int socketType,
ByteBuffer buffer,
int position,
int limit)
throws ExceptionUDT
DirectByteBuffer
ExceptionUDT
protected static long receiveFile0(int socketID,
String path,
long offset,
long length,
int block)
throws ExceptionUDT
ExceptionUDT
public static int selectEpoll(int epollId,
IntBuffer readBuffer,
IntBuffer writeBuffer,
IntBuffer sizeBuffer,
long millisTimeout)
throws ExceptionUDT
DirectIntBuffer info exchange.Timeout is in
milliseconds.
millisTimeout - http://udt.sourceforge.net/udt4/doc/epoll.htm
"Finally, for epoll_wait, negative timeout value will make the
function to wait until an event happens. If the timeout value
is 0, then the function returns immediately with any sockets
associated an IO event. If timeout occurs before any event
happens, the function returns 0".
<0 : should not happen=0 : timeout, no ready sockets>0 : total number or reads, writes, exceptionsExceptionUDTepollWait0(int, IntBuffer, IntBuffer, IntBuffer, long)
protected static int send0(int socketID,
int socketType,
int timeToLive,
boolean isOrdered,
byte[] array)
throws ExceptionUDT
ExceptionUDT
protected static int send1(int socketID,
int socketType,
int timeToLive,
boolean isOrdered,
byte[] array,
int arayPosition,
int arrayLimit)
throws ExceptionUDT
ExceptionUDT
protected static int send2(int socketID,
int socketType,
int timeToLive,
boolean isOrdered,
ByteBuffer buffer,
int bufferPosition,
int bufferLimit)
throws ExceptionUDT
DirectByteBuffer;
wrapper for UDT::send(), UDT::sendmsg()
ExceptionUDT
protected static long sendFile0(int socketID,
String path,
long offset,
long length,
int block)
throws ExceptionUDT
ExceptionUDT
protected static void stopClass0()
throws ExceptionUDT
ExceptionUDTprotected static void testCrashJVM0()
protected static void testDirectByteBufferAccess0(ByteBuffer buffer)
protected static void testDirectIntBufferAccess0(IntBuffer buffer)
protected static void testDirectIntBufferLoad0(IntBuffer buffer)
protected static void testEmptyCall0()
protected static void testFillArray0(byte[] array)
protected static void testFillBuffer0(ByteBuffer buffer)
protected static void testGetSetArray0(int[] array,
boolean isReturn)
protected static void testInvalidClose0(int socketID)
throws ExceptionUDT
ExceptionUDTprotected static void testIterateArray0(Object[] array)
protected static void testIterateSet0(Set<Object> set)
protected static int[] testMakeArray0(int size)
public SocketUDT accept()
throws ExceptionUDT
ExceptionUDT
protected SocketUDT accept0()
throws ExceptionUDT
ExceptionUDT
public void bind(InetSocketAddress localSocketAddress)
throws ExceptionUDT,
IllegalArgumentException
ExceptionUDT
IllegalArgumentException
protected void bind0(InetSocketAddress localSocketAddress)
throws ExceptionUDT
ExceptionUDTpublic void clearError()
protected void clearError0()
public void close()
throws ExceptionUDT
ExceptionUDTclose0()
protected void close0()
throws ExceptionUDT
ExceptionUDT
public void connect(InetSocketAddress remoteSocketAddress)
throws ExceptionUDT
Can be blocking or non blocking call; depending on
OptionUDT.Is_Receive_Synchronous
Timing: UDT uses hard coded connect timeout:
normal socket: 3 seconds
rendezvous socket: 30 seconds; when
OptionUDT.Is_Randezvous_Connect_Enabled is true
ExceptionUDTconnect0(InetSocketAddress)
protected void connect0(InetSocketAddress remoteSocketAddress)
throws ExceptionUDT
ExceptionUDTpublic boolean equals(Object otherSocketUDT)
socketID.
equals in class Objectprotected void finalize()
NOTE: do not leak "this" references; else prevents GC
finalize in class Objectpublic ErrorUDT getError()
public int getErrorCode()
protected int getErrorCode0()
public String getErrorMessage()
protected String getErrorMessage0()
public int getListenQueueSize()
listen(int)public InetAddress getLocalInetAddress()
bind(InetSocketAddress)public int getLocalInetPort()
bind(InetSocketAddress)
public InetSocketAddress getLocalSocketAddress()
throws ExceptionUDT
ExceptionUDThasLoadedLocalSocketAddress()public boolean getMessageIsOdered()
public int getMessageTimeTolLive()
public <T> T getOption(OptionUDT<T> option)
throws ExceptionUDT
ExceptionUDTgetOption0(int, Class)
protected Object getOption0(int code,
Class<?> klaz)
throws ExceptionUDT
ExceptionUDT
public int getReceiveBufferSize()
throws ExceptionUDT
ExceptionUDTSocket.getReceiveBufferSize()public InetAddress getRemoteInetAddress()
connect(InetSocketAddress)public int getRemoteInetPort()
connect(InetSocketAddress)
public InetSocketAddress getRemoteSocketAddress()
throws ExceptionUDT
ExceptionUDThasLoadedRemoteSocketAddress()
public boolean getReuseAddress()
throws ExceptionUDT
ExceptionUDTSocket.getReuseAddress()
public int getSendBufferSize()
throws ExceptionUDT
ExceptionUDTSocket.getSendBufferSize()
public int getSoLinger()
throws ExceptionUDT
ExceptionUDTSocket.getSoLinger()
public int getSoTimeout()
throws ExceptionUDT
ExceptionUDTSocket.getSoTimeout()protected int getStatus0()
public int hashCode()
socketID as hash code.
hashCode in class Objectprotected boolean hasLoadedLocalSocketAddress()
localSocketAddress value.
protected boolean hasLoadedRemoteSocketAddress()
remoteSocketAddress value.
public int id()
protected int initInstance0(int typeCode)
throws ExceptionUDT
ExceptionUDT
protected int initInstance1(int socketUDT)
throws ExceptionUDT
ExceptionUDTpublic boolean isBlocking()
isNonBlocking(),
setBlocking(boolean)public boolean isBound()
bind(InetSocketAddress) was successfulpublic boolean isClosed()
isOpen()public boolean isConnected()
KindUDT.CONNECTOR socket is connected. (JDK semantics)
connect(InetSocketAddress) was successfulpublic boolean isNonBlocking()
isBlocking(),
setBlocking(boolean)public boolean isOpen()
StatusUDTpublic boolean isRendezvous()
public void listen(int queueSize)
throws ExceptionUDT
queueSize - maximum number of queued clients
ExceptionUDTlisten0(int)
protected void listen0(int queueSize)
throws ExceptionUDT
ExceptionUDTpublic MonitorUDT monitor()
updateMonitor(boolean) in JNI
updateMonitor(boolean)
public int receive(byte[] array)
throws ExceptionUDT
array.length bytes
-1 : nothing received (non-blocking only)=0 : timeout expired (blocking only)>0 : normal receive, byte countExceptionUDTreceive0(int, int, byte[])
public int receive(byte[] array,
int position,
int limit)
throws ExceptionUDT
size=limit-position bytes
-1 : nothing received (non-blocking only)=0 : timeout expired (blocking only)>0 : normal receive, byte countExceptionUDTreceive1(int, int, byte[], int, int)
public int receive(ByteBuffer buffer)
throws ExceptionUDT
DirectByteBuffer; upto
Buffer.remaining() bytes
-1 : nothing received (non-blocking only)=0 : timeout expired (blocking only)>0 : normal receive, byte countExceptionUDTreceive2(int, int, ByteBuffer, int, int)
public long receiveFile(File file,
long offset,
long length)
throws ExceptionUDT
ExceptionUDTreceiveFile0(int, String, long, long, int)
public int send(byte[] array)
throws ExceptionUDT
size=array.length bytes
array - array to send
-1 : no buffer space (non-blocking only) =0 : timeout expired (blocking only) >0 : normal send, actual sent byte count ExceptionUDTsend0(int, int, int, boolean, byte[])
public int send(byte[] array,
int position,
int limit)
throws ExceptionUDT
size=limit-position bytes
array - array to sendposition - start of array portion to sendlimit - finish of array portion to send
-1 : no buffer space (non-blocking only) =0 : timeout expired (blocking only) >0 : normal send, actual sent byte count ExceptionUDTsend1(int, int, int, boolean, byte[], int, int)
public int send(ByteBuffer buffer)
throws ExceptionUDT
DirectByteBuffer, upto
Buffer.remaining() bytes
buffer - buffer to send
-1 : no buffer space (non-blocking only)=0 : timeout expired (blocking only)>0 : normal send, actual sent byte countExceptionUDTsend2(int, int, int, boolean, ByteBuffer, int, int)
public long sendFile(File file,
long offset,
long length)
throws ExceptionUDT
ExceptionUDTsendFile0(int, String, long, long, int)
public void setBlocking(boolean block)
throws ExceptionUDT
block - true : set both send and receive to blocking mode; false : set
both send and receive to non-blocking mode
ExceptionUDTAbstractSelectableChannel.configureBlocking(boolean)public void setDefaultMessageSendMode()
IsOdered = true;
TimeTolLive = INFINITE_TTL;
public void setMessageIsOdered(boolean isOrdered)
public void setMessageTimeTolLive(int timeToLive)
public <T> void setOption(OptionUDT<T> option,
T value)
throws ExceptionUDT
ExceptionUDTsetOption0(int, Class, Object)
protected void setOption0(int code,
Class<?> klaz,
Object value)
throws ExceptionUDT
ExceptionUDT
public void setReceiveBufferSize(int size)
throws ExceptionUDT
ExceptionUDT
public void setRendezvous(boolean isOn)
throws ExceptionUDT
ExceptionUDT
public void setReuseAddress(boolean on)
throws ExceptionUDT
ExceptionUDT
public void setSendBufferSize(int size)
throws ExceptionUDT
ExceptionUDTSocket.setSendBufferSize(int)
public void setSoLinger(boolean on,
int linger)
throws ExceptionUDT
ExceptionUDT
public void setSoTimeout(int millisTimeout)
throws ExceptionUDT
ExceptionUDTpublic StatusUDT status()
public String toString()
toString in class Objectpublic String toStringMonitor()
public String toStringOptions()
public TypeUDT type()
public void updateMonitor(boolean makeClear)
throws ExceptionUDT
monitor object. Must call
this methos only on connected socket.
makeClear - true : reset all statistics with this call; false : keep
collecting statistics, load updated values.
ExceptionUDTupdateMonitor0(boolean)
protected void updateMonitor0(boolean makeClear)
throws ExceptionUDT
ExceptionUDT
|
barchart-udt-core 2.3.0-SNAPSHOT / 2013-05-13T01:37:38.485-0500 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||