net.sf.infrared.agent
Class ApiTime

java.lang.Object
  extended bynet.sf.infrared.agent.ApiTime
All Implemented Interfaces:
Serializable

public class ApiTime
extends Object
implements Serializable

This class measures and stores the timing information of an API execution.

This can be used to record the start and end times of an API execution.

See Also:
Serialized Form

Constructor Summary
ApiTime(ApiTime anotherApiTime)
           
ApiTime(ApiTime anotherApiTime, IdMapper idMapper)
          Copy constructor for making a new ApiTime with the same attributes as a given ApiTime.
ApiTime(String apiName, String apiType)
          Constructs an ApiTime representing a given API and which is of a given type.
 
Method Summary
 boolean equals(Object o)
           
 Api getApi()
           
 String getApiName()
          Gets the name of the API reprsented by this ApiTime.
 String getApiType()
          Gets the type of the API represented by this ApiTime.
 SqlStatisticsMap getSqlStatisticsMap()
           
 long getTime()
          Gets the time which the API represented by this ApiTime took for execution.
 int hashCode()
           
 boolean hasSqlStatistics()
           
 void recordExecuteError(Long id, long time, boolean prepared)
          Record a failed execute
 void recordExecuteSql(Long id, long time, boolean prepared)
          Record a call to execute a statement
 void recordFetchComplete(Long id, long noOfRowsFetched, long timeTakenForFetch)
           
 void recordPrepareSql(Long id, long time)
          Record a call to prepare a sql statement
 void setTime(long time)
           
 String toString()
          String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ApiTime

public ApiTime(String apiName,
               String apiType)
Constructs an ApiTime representing a given API and which is of a given type. The startTime, endTime and executionTime of the newly constructed ApiTime is unspecified i.e. -1.

Parameters:
apiName - the name of the API whose execution this ApiTime represents
apiType - the type of the API, typically the layer in which this API is invoked, can be null
Throws:
IllegalArgumentException - if apiName or apiType specified if null

ApiTime

public ApiTime(ApiTime anotherApiTime,
               IdMapper idMapper)
Copy constructor for making a new ApiTime with the same attributes as a given ApiTime.

Parameters:
anotherApiTime - the ApiTime whose copy is to be made.

ApiTime

public ApiTime(ApiTime anotherApiTime)
Method Detail

getApiName

public String getApiName()
Gets the name of the API reprsented by this ApiTime.

Returns:
name of API, always non-null

getApiType

public String getApiType()
Gets the type of the API represented by this ApiTime.

Returns:
type of API, always non-null

getTime

public long getTime()
Gets the time which the API represented by this ApiTime took for execution. Execution time is calculated as : executionTime = endTime - startTime;

Returns:
execution time, if both startTime and endTime has been set; else -1.

setTime

public void setTime(long time)

toString

public String toString()
String representation of this object.

Returns:
apiName

equals

public boolean equals(Object o)

hashCode

public int hashCode()

getApi

public Api getApi()

recordPrepareSql

public void recordPrepareSql(Long id,
                             long time)
Record a call to prepare a sql statement

Parameters:
id - - id of sql query
time - - time spent in preparing

recordExecuteSql

public void recordExecuteSql(Long id,
                             long time,
                             boolean prepared)
Record a call to execute a statement

Parameters:
id - - id of sql query
time - - time spent in executing the query
prepared - - was it a prepared statement or plain statement

recordExecuteError

public void recordExecuteError(Long id,
                               long time,
                               boolean prepared)
Record a failed execute

Parameters:
id - - id of sql query
time - - time spent in executing the query
prepared - - was it a prepared statement or plain statement

getSqlStatisticsMap

public SqlStatisticsMap getSqlStatisticsMap()

hasSqlStatistics

public boolean hasSqlStatistics()

recordFetchComplete

public void recordFetchComplete(Long id,
                                long noOfRowsFetched,
                                long timeTakenForFetch)