org.edg.info
Class SocketUtils

java.lang.Object
  extended byorg.edg.info.SocketUtils

public class SocketUtils
extends java.lang.Object

Class SocketUtils


Field Summary
static long CONNECT_TIMEOUT_MS
          Maximum time to wait for socket connect (in ms).
static int FINISH_CONNECT_RETRY_PERIOD_MS
          Period to wait between attempts to finish connection (in ms).
static long FINISH_WRITE_ID_RETRY_PERIOD_MS
          Period to wait between attempts to "finish" writing consumer ID (in ms).
static long WRITE_ID_TIMEOUT_MS
          Maximum time to wait for ID write (in ms).
 
Method Summary
static void closeSocketChannel(java.nio.channels.SocketChannel socketChannel)
          Closes the given socket channel and shuts down its input and output.
static java.nio.channels.SocketChannel createSocketChannel(org.edg.info.system.StreamRequest request)
          Create a SocketChannel in blocking mode
static java.nio.channels.SocketChannel createSocketChannel(org.edg.info.system.StreamRequest request, boolean blocking)
          Creates a new SocketChannel to the Streaming URL and Port in the request.
static void writeEndResultToken(java.nio.channels.SocketChannel socketChannel)
          Writes a ResultSet to a SocketChannel terminated by an END_ONETIME_RESULT_TOKEN.
static void writeOneOffString(java.nio.channels.SocketChannel socketChannel, java.lang.String responseFromUserCode)
           
static void writeResultSet(java.nio.channels.SocketChannel socketChannel, org.glite.rgma.system.ResultSet result)
          Writes a ResultSet to a SocketChannel
static void writeString(java.nio.channels.SocketChannel socketChannel, java.lang.String str)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONNECT_TIMEOUT_MS

public static final long CONNECT_TIMEOUT_MS
Maximum time to wait for socket connect (in ms).

See Also:
Constant Field Values

WRITE_ID_TIMEOUT_MS

public static final long WRITE_ID_TIMEOUT_MS
Maximum time to wait for ID write (in ms).

See Also:
Constant Field Values

FINISH_CONNECT_RETRY_PERIOD_MS

public static final int FINISH_CONNECT_RETRY_PERIOD_MS
Period to wait between attempts to finish connection (in ms).

See Also:
Constant Field Values

FINISH_WRITE_ID_RETRY_PERIOD_MS

public static final long FINISH_WRITE_ID_RETRY_PERIOD_MS
Period to wait between attempts to "finish" writing consumer ID (in ms).

See Also:
Constant Field Values
Method Detail

closeSocketChannel

public static void closeSocketChannel(java.nio.channels.SocketChannel socketChannel)
Closes the given socket channel and shuts down its input and output.

Parameters:
socketChannel - Channel to close.

createSocketChannel

public static java.nio.channels.SocketChannel createSocketChannel(org.edg.info.system.StreamRequest request)
                                                           throws org.glite.rgma.system.RGMAInternalException,
                                                                  org.edg.info.system.ConnectionTimedOutException
Create a SocketChannel in blocking mode

Throws:
org.glite.rgma.system.RGMAInternalException
org.edg.info.system.ConnectionTimedOutException
See Also:
createSocketChannel

createSocketChannel

public static java.nio.channels.SocketChannel createSocketChannel(org.edg.info.system.StreamRequest request,
                                                                  boolean blocking)
                                                           throws org.glite.rgma.system.RGMAInternalException,
                                                                  org.edg.info.system.ConnectionTimedOutException
Creates a new SocketChannel to the Streaming URL and Port in the request. If creation fails, but it's possible that it could succeed in the future, null is returned and no exception is thrown.

Parameters:
request - Provides details of streaming destination (URL & port)
blocking - Whether to set the resulting channel in blocking mode
Returns:
A socketChannel to the given destination, or null if the socket couldn't be opened but should be retried.
Throws:
RGMAException - Thrown if the socketChannel could not be created and there is no hope of it ever being created.
org.glite.rgma.system.RGMAInternalException
org.edg.info.system.ConnectionTimedOutException

writeResultSet

public static void writeResultSet(java.nio.channels.SocketChannel socketChannel,
                                  org.glite.rgma.system.ResultSet result)
                           throws java.io.IOException
Writes a ResultSet to a SocketChannel

Parameters:
socketChannel - Remote socket to send to.
result - ResultSet to write.
Throws:
java.io.IOException - Thrown if socket channel write fails.

writeString

public static void writeString(java.nio.channels.SocketChannel socketChannel,
                               java.lang.String str)
                        throws java.io.IOException
Parameters:
socketChannel -
str -
Throws:
java.io.IOException

writeEndResultToken

public static void writeEndResultToken(java.nio.channels.SocketChannel socketChannel)
                                throws java.io.IOException
Writes a ResultSet to a SocketChannel terminated by an END_ONETIME_RESULT_TOKEN.

Parameters:
socketChannel - Remote socket to send to.
Throws:
java.io.IOException - Thrown if socket channel write fails.

writeOneOffString

public static void writeOneOffString(java.nio.channels.SocketChannel socketChannel,
                                     java.lang.String responseFromUserCode)
                              throws org.glite.rgma.system.RGMAInternalException
Parameters:
socketChannel -
responseFromUserCode -
Throws:
org.glite.rgma.system.RGMAInternalException