ParkNPark.common
Class CommandLineParser

java.lang.Object
  extended by ParkNPark.common.CommandLineParser

public class CommandLineParser
extends Object

Parses a command line using GNU GetOpt


Nested Class Summary
static class CommandLineParser.AcceptedParameters
          Enumeration of the accepted commands that the caller wants
 
Field Summary
protected  boolean appendLogs
          When true, logs should be appended; when false, logs should be overwritten
protected  int detectionTimeout
          The wait timeout to use during fault detections
protected  boolean faultInjection
          Whether or not fault injection is enabled
protected  int faultInjectionMaxDelay
          The maximum delay of the fault injection in milliseconds
protected  int faultInjectionMinDelay
          The minimum delay of the fault injection in milliseconds
protected  int getLotsModeCount
          When not 0, how many invocations of getLotsMode should be performed
protected  int interRequestTime
          The inter-request time in this test run in milliseconds
private  String jdbcPassword
          The JDBC password
protected  String jdbcURL
          The JDBC URL
private  String jdbcUsername
          The JDBC user name
protected  boolean killOnly
          When true, the testing manager will only kill everything
protected  boolean neverGiveUp
          When true, never give up when trying to contact the server
protected  int numClients
          The number of clients in this test run
protected  int numServers
          The number of servers in this test run
protected  String projectRoot
          Our project root folder
protected  int recoveryTimeout
          The wait timeout to use during fault recoveries
protected  int replySize
          The reply size of the server messages in this test run in bytes
 
Constructor Summary
CommandLineParser()
           
 
Method Summary
 int getFaultDetectionTimeout()
          Returns the fault detection timeout
 int getFaultInjectionMaxDelay()
          Returns the maximum delay of the fault injector in milliseconds
 int getFaultInjectionMinDelay()
          Returns the minimum delay of the fault injector in milliseconds
 int getFaultRecoveryTimeout()
          Returns the fault recovery timeout
 int getGetLotsModeCount()
          When not 0, how many invocations of getLotsMode should be performed
 int getInterRequestTime()
          Returns the inter-request time in this test run
 String getJDBCPassword()
          Returns the JDBC password
 String getJDBCURL()
          Returns the JDBC URL
 String getJDBCUsername()
          Returns the JDBC username
 int getNumClients()
          Returns the number of clients in this test run
 int getNumServers()
          Returns the number of servers in this test run
 String getProjectRoot()
          Returns the project root folder or null if none was given in the command line arguments
 int getReplySize()
          Returns the reply size of the server messages in this test run
protected  void help(String name, Set<CommandLineParser.AcceptedParameters> acceptedParameters)
          Writes out our command line help text to stdout using the given program name
 boolean isFaultInjectionEnabled()
          Returns true when fault injection is enabled or false when it is disabled
 boolean parseCommandLine(String name, String[] args, Set<CommandLineParser.AcceptedParameters> acceptedParameters)
          Parses the given command line for the given program name and returns true if the command line was successfully parsed or false if the program should exit
 boolean shouldAppendLogs()
          Returns true when log files should be appended or false when logs files should be overwritten
 boolean shouldKillOnly()
          Returns whether or not the testing manager should only kill everything and exit
 boolean shouldNeverGiveUp()
          Returns true when the program should never give up when trying to reach a server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

replySize

protected int replySize
The reply size of the server messages in this test run in bytes


numClients

protected int numClients
The number of clients in this test run


numServers

protected int numServers
The number of servers in this test run


interRequestTime

protected int interRequestTime
The inter-request time in this test run in milliseconds


faultInjection

protected boolean faultInjection
Whether or not fault injection is enabled


appendLogs

protected boolean appendLogs
When true, logs should be appended; when false, logs should be overwritten


neverGiveUp

protected boolean neverGiveUp
When true, never give up when trying to contact the server


faultInjectionMinDelay

protected int faultInjectionMinDelay
The minimum delay of the fault injection in milliseconds


faultInjectionMaxDelay

protected int faultInjectionMaxDelay
The maximum delay of the fault injection in milliseconds


projectRoot

protected String projectRoot
Our project root folder


getLotsModeCount

protected int getLotsModeCount
When not 0, how many invocations of getLotsMode should be performed


killOnly

protected boolean killOnly
When true, the testing manager will only kill everything


detectionTimeout

protected int detectionTimeout
The wait timeout to use during fault detections


recoveryTimeout

protected int recoveryTimeout
The wait timeout to use during fault recoveries


jdbcURL

protected String jdbcURL
The JDBC URL


jdbcUsername

private String jdbcUsername
The JDBC user name


jdbcPassword

private String jdbcPassword
The JDBC password

Constructor Detail

CommandLineParser

public CommandLineParser()
Method Detail

parseCommandLine

public boolean parseCommandLine(String name,
                                String[] args,
                                Set<CommandLineParser.AcceptedParameters> acceptedParameters)
Parses the given command line for the given program name and returns true if the command line was successfully parsed or false if the program should exit

Parameters:
name - The name of the program
args - The arguments passed in from the command line
acceptedParameters - Set of accepted parameters that the caller is interested in
Returns:
True if the program can continue or false if the program should exit

help

protected void help(String name,
                    Set<CommandLineParser.AcceptedParameters> acceptedParameters)
Writes out our command line help text to stdout using the given program name

Parameters:
name - The program name to use when displaying the command line help
acceptedParameters - Set of accepted parameters that the caller is interested in

getInterRequestTime

public int getInterRequestTime()
Returns the inter-request time in this test run

Returns:
The inter-request time in this test run

getNumClients

public int getNumClients()
Returns the number of clients in this test run

Returns:
The number of clients in this test run

getNumServers

public int getNumServers()
Returns the number of servers in this test run

Returns:
The number of servers in this test run

getReplySize

public int getReplySize()
Returns the reply size of the server messages in this test run

Returns:
The reply size of the server messages in this test run

isFaultInjectionEnabled

public boolean isFaultInjectionEnabled()
Returns true when fault injection is enabled or false when it is disabled

Returns:
True when fault injection is enabled or false when it is disabled

getFaultInjectionMinDelay

public int getFaultInjectionMinDelay()
Returns the minimum delay of the fault injector in milliseconds

Returns:
The minimum delay of the fault injector in milliseconds

getFaultInjectionMaxDelay

public int getFaultInjectionMaxDelay()
Returns the maximum delay of the fault injector in milliseconds

Returns:
The maximum delay of the fault injector in milliseconds

shouldAppendLogs

public boolean shouldAppendLogs()
Returns true when log files should be appended or false when logs files should be overwritten

Returns:
True when log files should be appended or false when logs files should be overwritten

shouldNeverGiveUp

public boolean shouldNeverGiveUp()
Returns true when the program should never give up when trying to reach a server. Otherwise, a client can give up if no primary server is registered, for example

Returns:
True when the program should never give up when trying to reach a server

shouldKillOnly

public boolean shouldKillOnly()
Returns whether or not the testing manager should only kill everything and exit

Returns:
Whether or not the testing manager should only kill everything and exit

getProjectRoot

public String getProjectRoot()
Returns the project root folder or null if none was given in the command line arguments

Returns:
The project root folder or null if none was given in the command line arguments

getGetLotsModeCount

public int getGetLotsModeCount()
When not 0, how many invocations of getLotsMode should be performed

Returns:
When not 0, how many invocations of getLotsMode should be performed

getFaultRecoveryTimeout

public int getFaultRecoveryTimeout()
Returns the fault recovery timeout

Returns:
The fault recovery timeout

getFaultDetectionTimeout

public int getFaultDetectionTimeout()
Returns the fault detection timeout

Returns:
The fault detection timeout

getJDBCURL

public String getJDBCURL()
Returns the JDBC URL

Returns:
The JDBC URL

getJDBCUsername

public String getJDBCUsername()
Returns the JDBC username

Returns:
The JDBC username

getJDBCPassword

public String getJDBCPassword()
Returns the JDBC password

Returns:
The JDBC password