org.rhq.enterprise.communications.util
Class CommandTraceUtil

java.lang.Object
  extended by org.rhq.enterprise.communications.util.CommandTraceUtil

public class CommandTraceUtil
extends Object

Static utility methods useful when logging commands, used mainly for debugging a client and remote endpoint.

Author:
John Mazzitelli

Constructor Summary
CommandTraceUtil()
           
 
Method Summary
static int getCommandResponseSize(Object response)
          Returns the actual size, in bytes, of the given response but only if it exceeds the given configured threshold (-1 is returned otherwise).
static String getCommandResponseString(Object response)
          Returns a good string to use to log the command response.
static int getCommandSize(Command command)
          Returns the actual size, in bytes, of the given command but only if it exceeds the given configured threshold (-1 is returned otherwise).
static String getCommandString(Command command)
          Returns a good string to use to log the command.
static String getConfigString(Command command)
          Returns the string that represents the command configuration.
static Boolean getSettingTraceCommandConfig()
           
static Integer getSettingTraceCommandResponseResults()
           
static Integer getSettingTraceCommandResponseSizeThreshold()
           
static Integer getSettingTraceCommandSizeThreshold()
           
static void setSettingTraceCommandConfig(Boolean val)
           
static void setSettingTraceCommandResponseResults(Integer val)
           
static void setSettingTraceCommandResponseSizeThreshold(Integer val)
           
static void setSettingTraceCommandSizeThreshold(Integer val)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandTraceUtil

public CommandTraceUtil()
Method Detail

getSettingTraceCommandConfig

public static Boolean getSettingTraceCommandConfig()

setSettingTraceCommandConfig

public static void setSettingTraceCommandConfig(Boolean val)

getSettingTraceCommandResponseResults

public static Integer getSettingTraceCommandResponseResults()

setSettingTraceCommandResponseResults

public static void setSettingTraceCommandResponseResults(Integer val)

getSettingTraceCommandSizeThreshold

public static Integer getSettingTraceCommandSizeThreshold()

setSettingTraceCommandSizeThreshold

public static void setSettingTraceCommandSizeThreshold(Integer val)

getSettingTraceCommandResponseSizeThreshold

public static Integer getSettingTraceCommandResponseSizeThreshold()

setSettingTraceCommandResponseSizeThreshold

public static void setSettingTraceCommandResponseSizeThreshold(Integer val)

getConfigString

public static String getConfigString(Command command)
Returns the string that represents the command configuration.

Parameters:
command - the command whose configuration is stringified and returned
Returns:
the stringified configuration

getCommandString

public static String getCommandString(Command command)
Returns a good string to use to log the command. If this is a remote pojo invocation command, this will return the remote pojo method being invoked; otherwise, its the command's type name.

Parameters:
command - the command to convert to a string
Returns:
the command's string that should be logged

getCommandResponseString

public static String getCommandResponseString(Object response)
Returns a good string to use to log the command response.

Parameters:
response - the command response to convert to a string
Returns:
the command response string that should be logged

getCommandSize

public static int getCommandSize(Command command)
                          throws NotSerializableException
Returns the actual size, in bytes, of the given command but only if it exceeds the given configured threshold (-1 is returned otherwise). If size tracing threshold is disabled, this will not perform any serialization and simply return -1 (SYSPROP_TRACE_COMMAND_SIZE_THRESHOLD defines this threshold). Note that if the command is not serializable, an exception is thrown. All commands must be serializable; therefore, if we trace a command that is not, it is appropriate for us to draw attention to it by throwing an exception from this method.

Parameters:
command -
Returns:
the size of the command or -1 if not configured to perform size tracing
Throws:
NotSerializableException - if failed to serialize the command

getCommandResponseSize

public static int getCommandResponseSize(Object response)
                                  throws NotSerializableException
Returns the actual size, in bytes, of the given response but only if it exceeds the given configured threshold (-1 is returned otherwise). If size tracing threshold is disabled, this will not perform any serialization and simply return -1 (see SYSPROP_TRACE_COMMAND_RESPONSE_SIZE_THRESHOLD defines this threshold). Note that if the response is not serializable, a runtime exception is thrown. All responses must be serializable; therefore, if we trace a response that is not, it is appropriate for us to draw attention to it by throwing an exception from this method.

Parameters:
response -
Returns:
the size of the response or -1 if not configured to perform size tracing
Throws:
NotSerializableException - if failed to serialize the response


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.