CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.net
Class DatagramTest

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.DatagramTest

public class DatagramTest
extends Base

Test for datagram communication.

Author:
cp, mf 2005.10.24

Nested Class Summary
static class DatagramTest.DatagramListener
           
static class DatagramTest.DatagramPublisher
          The publisher test.
static class DatagramTest.ListenerConfig
          Holder for Listener configuration.
protected static class DatagramTest.PacketTracker
          Tracker of packet statistics for a single client.
static class DatagramTest.PublisherConfig
          Holder for Publisher configuration.
protected static class DatagramTest.StartFlag
          The start flag is used to allow a listener to control a inner process publisher.
static class DatagramTest.TestConfiguration
          Holder for Test configuration.
 
Field Summary
static String COMMAND_ADDR_LOCAL
           
static String COMMAND_LOG
           
static String COMMAND_LOG_INTERVAL
           
static String COMMAND_PACKET_SIZE
           
static String COMMAND_PAYLOAD
           
static String COMMAND_PROCESS_BYTES
           
static String COMMAND_REPORT_INTERVAL
           
static String COMMAND_RX_PACKET_BUFFER_SIZE
           
static String COMMAND_RX_TIMEOUT_MS
           
static String COMMAND_TICK_INTERVAL
           
static String COMMAND_TX_DURATION_MS
           
static String COMMAND_TX_ITERATIONS
           
static String COMMAND_TX_PACKET_BUFFER_SIZE
           
static String COMMAND_TX_RATE
           
static String DEFAULT_ADDR_LOCAL
           
static String DEFAULT_IP_LOCAL
           
static String DEFAULT_LOG
           
static int DEFAULT_LOG_INTERVAL
           
static int DEFAULT_PACKET_SIZE
           
static int DEFAULT_PAYLOAD
           
static int DEFAULT_PORT
           
static int DEFAULT_PROCESS_BYTES
           
static int DEFAULT_REPORT_INTERVAL
           
static int DEFAULT_RX_PACKET_BUFFER_SIZE
           
static int DEFAULT_RX_TIMEOUT_MS
           
static int DEFAULT_TICK_INTERVAL
           
static long DEFAULT_TX_DURATION_MS
           
static int DEFAULT_TX_ITERATIONS
           
static int DEFAULT_TX_PACKET_BUFFER_SIZE
           
static int DEFAULT_TX_RATE
           
static int MB
           
static String SWITCH_HELP
           
static String SWITCH_POLITE
           
static String SWITCH_RAND
           
static String[] VALID_COMMANDS
           
static String[] VALID_SWITCHES
           
 
Constructor Summary
DatagramTest()
           
 
Method Summary
static boolean checkProcessPacketBytes(int cbPacket, int cProcessPacketBytes)
          Check that the value for processPacketBytes is acceptable.
static String computeThroughputMBPerSec(long cBytes, long lDurationMs)
          Compute throughput as megabytes per second.
static String computeThroughputPacketsPerSec(int cPackets, long lDurationMs)
          Compute throughput as packets per second.
protected static List extractSwitches(Collection colArg, String[] asValidSwitch)
          Search the supplied argument set for known switches, and extract them.
static void main(String[] asArg)
          Parse and validate the command-line parameters and run the test.
protected static Object processCommand(Map mapCommands, String sName)
          Process a command from the command line arguments.
protected static Object processCommand(Map mapCommands, String sName, Object oDefault)
          Process a command from the command line arguments.
protected static int processIntCommand(Map mapCommands, String sName)
          Process a required command from the command line arguments, where the value is to be interpreted as an integer.
protected static int processIntCommand(Map mapCommands, String sName, int iDefault)
          Process an optional command from the command line arguments, where the value is to be interpreted as an integer.
protected static long processLongCommand(Map mapCommands, String sName, long lDefault)
          Process an optional command from the command line arguments, where the value is to be interpreted as an long.
protected static void showInstructions()
          Display the command-line instructions.
protected static InetSocketAddress translateAddress(String sAddr)
          Convert an address:port string to an InetSocketAddress.
 

Field Detail

MB

public static final int MB
See Also:
Constant Field Values

COMMAND_ADDR_LOCAL

public static final String COMMAND_ADDR_LOCAL
See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DEFAULT_IP_LOCAL

public static final String DEFAULT_IP_LOCAL
See Also:
Constant Field Values

DEFAULT_ADDR_LOCAL

public static final String DEFAULT_ADDR_LOCAL
See Also:
Constant Field Values

COMMAND_PACKET_SIZE

public static final String COMMAND_PACKET_SIZE
See Also:
Constant Field Values

DEFAULT_PACKET_SIZE

public static final int DEFAULT_PACKET_SIZE
See Also:
Constant Field Values

COMMAND_PAYLOAD

public static final String COMMAND_PAYLOAD
See Also:
Constant Field Values

DEFAULT_PAYLOAD

public static final int DEFAULT_PAYLOAD
See Also:
Constant Field Values

COMMAND_TX_RATE

public static final String COMMAND_TX_RATE
See Also:
Constant Field Values

DEFAULT_TX_RATE

public static final int DEFAULT_TX_RATE
See Also:
Constant Field Values

COMMAND_PROCESS_BYTES

public static final String COMMAND_PROCESS_BYTES
See Also:
Constant Field Values

DEFAULT_PROCESS_BYTES

public static final int DEFAULT_PROCESS_BYTES
See Also:
Constant Field Values

COMMAND_TX_PACKET_BUFFER_SIZE

public static final String COMMAND_TX_PACKET_BUFFER_SIZE
See Also:
Constant Field Values

DEFAULT_TX_PACKET_BUFFER_SIZE

public static final int DEFAULT_TX_PACKET_BUFFER_SIZE
See Also:
Constant Field Values

COMMAND_RX_PACKET_BUFFER_SIZE

public static final String COMMAND_RX_PACKET_BUFFER_SIZE
See Also:
Constant Field Values

DEFAULT_RX_PACKET_BUFFER_SIZE

public static final int DEFAULT_RX_PACKET_BUFFER_SIZE
See Also:
Constant Field Values

COMMAND_LOG

public static final String COMMAND_LOG
See Also:
Constant Field Values

DEFAULT_LOG

public static final String DEFAULT_LOG

COMMAND_REPORT_INTERVAL

public static final String COMMAND_REPORT_INTERVAL
See Also:
Constant Field Values

DEFAULT_REPORT_INTERVAL

public static final int DEFAULT_REPORT_INTERVAL
See Also:
Constant Field Values

COMMAND_LOG_INTERVAL

public static final String COMMAND_LOG_INTERVAL
See Also:
Constant Field Values

DEFAULT_LOG_INTERVAL

public static final int DEFAULT_LOG_INTERVAL
See Also:
Constant Field Values

COMMAND_TICK_INTERVAL

public static final String COMMAND_TICK_INTERVAL
See Also:
Constant Field Values

DEFAULT_TICK_INTERVAL

public static final int DEFAULT_TICK_INTERVAL
See Also:
Constant Field Values

COMMAND_TX_ITERATIONS

public static final String COMMAND_TX_ITERATIONS
See Also:
Constant Field Values

DEFAULT_TX_ITERATIONS

public static final int DEFAULT_TX_ITERATIONS
See Also:
Constant Field Values

COMMAND_TX_DURATION_MS

public static final String COMMAND_TX_DURATION_MS
See Also:
Constant Field Values

DEFAULT_TX_DURATION_MS

public static final long DEFAULT_TX_DURATION_MS
See Also:
Constant Field Values

COMMAND_RX_TIMEOUT_MS

public static final String COMMAND_RX_TIMEOUT_MS
See Also:
Constant Field Values

DEFAULT_RX_TIMEOUT_MS

public static final int DEFAULT_RX_TIMEOUT_MS
See Also:
Constant Field Values

VALID_COMMANDS

public static final String[] VALID_COMMANDS

SWITCH_HELP

public static final String SWITCH_HELP
See Also:
Constant Field Values

SWITCH_POLITE

public static final String SWITCH_POLITE
See Also:
Constant Field Values

SWITCH_RAND

public static final String SWITCH_RAND
See Also:
Constant Field Values

VALID_SWITCHES

public static final String[] VALID_SWITCHES
Constructor Detail

DatagramTest

public DatagramTest()
Method Detail

main

public static void main(String[] asArg)
Parse and validate the command-line parameters and run the test.

Parameters:
asArg - an array of command line parameters
See Also:
showInstructions()

extractSwitches

protected static List extractSwitches(Collection colArg,
                                      String[] asValidSwitch)
Search the supplied argument set for known switches, and extract them. Each switch which is found will be placed in the returned List and removed from the argument collection.

Parameters:
colArg - argument collection to parse, and remove switch from
asValidSwitch - switches to look for
Returns:
list of found switches

processCommand

protected static Object processCommand(Map mapCommands,
                                       String sName)
                                throws UnsupportedOperationException
Process a command from the command line arguments. This method is used to process required commands, and will throw an exception if the command was not specified.

Parameters:
mapCommands - the map of command line arguments
sName - the name of the command to process
Returns:
the value
Throws:
UnsupportedOperationException - if a no value is available

processCommand

protected static Object processCommand(Map mapCommands,
                                       String sName,
                                       Object oDefault)
                                throws UnsupportedOperationException
Process a command from the command line arguments. This method is used to process optional commands, and the default will be returned if command was not explicitly specified.

Parameters:
mapCommands - the map of command line arguments
sName - the name of the command to process
oDefault - Specifies a default value
Returns:
the value, or oDefault if unspecified
Throws:
UnsupportedOperationException

processIntCommand

protected static int processIntCommand(Map mapCommands,
                                       String sName,
                                       int iDefault)
                                throws UnsupportedOperationException
Process an optional command from the command line arguments, where the value is to be interpreted as an integer.

Parameters:
mapCommands - the map of command line arguments
sName - the name of the argument to process
iDefault - Specifies an default value
Returns:
the value, or iDefault if unspecified
Throws:
UnsupportedOperationException

processIntCommand

protected static int processIntCommand(Map mapCommands,
                                       String sName)
                                throws UnsupportedOperationException
Process a required command from the command line arguments, where the value is to be interpreted as an integer.

Parameters:
mapCommands - the map of command line arguments
sName - the name of the argument to process
Returns:
the value
Throws:
UnsupportedOperationException - if a no value is available

processLongCommand

protected static long processLongCommand(Map mapCommands,
                                         String sName,
                                         long lDefault)
                                  throws UnsupportedOperationException
Process an optional command from the command line arguments, where the value is to be interpreted as an long.

Parameters:
mapCommands - the map of command line arguments
sName - the name of the argument to process
lDefault - Specifies an default value
Returns:
the value, or iDefault if unspecified
Throws:
UnsupportedOperationException

translateAddress

protected static InetSocketAddress translateAddress(String sAddr)
                                             throws UnknownHostException
Convert an address:port string to an InetSocketAddress.

Parameters:
sAddr - a legal address string
Returns:
a non-null InetSocketAddress object
Throws:
UnknownHostException

checkProcessPacketBytes

public static boolean checkProcessPacketBytes(int cbPacket,
                                              int cProcessPacketBytes)
Check that the value for processPacketBytes is acceptable. To be acceptable it must be a positive multiple of 4, and less then the packet size.

Parameters:
cbPacket - the packet size
cProcessPacketBytes - the number of bytes to process from each packet
Returns:
true if the value is acceptable, false otherwise

computeThroughputMBPerSec

public static String computeThroughputMBPerSec(long cBytes,
                                               long lDurationMs)
Compute throughput as megabytes per second.

Parameters:
cBytes - the number of bytes transfered
lDurationMs - the time in milliseconds the transfer took
Returns:
throughput a human redable string for the throughput expressed in megabytes per second

computeThroughputPacketsPerSec

public static String computeThroughputPacketsPerSec(int cPackets,
                                                    long lDurationMs)
Compute throughput as packets per second.

Parameters:
cPackets - the number of packets transfered
lDurationMs - the time in milliseconds the transfer took
Returns:
throughput a human redable string for the throughput expressed in packets per second

showInstructions

protected static void showInstructions()
Display the command-line instructions.


CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation