org.e2etrace.trace
Class TraceSessionRootStep

java.lang.Object
  extended by org.e2etrace.trace.AbstractTraceStep
      extended by org.e2etrace.trace.TraceSessionRootStep
All Implemented Interfaces:
Serializable, ITraceStep

public class TraceSessionRootStep
extends AbstractTraceStep

Root trace step for ITraceSession.

Each trace session contains one implicit trace step that serves as root of the tree of "real" trace steps. The duration of this trace step is by definition the accumulated duration of all children. In additon, the isolated duration of this step is by definion 0ms.

In practice, an instance of the root step represents a complete service call. The children of the root step are the single execution steps of the service.

A root step can savely be added as child to any other trace step (e.g. if a client invokes a remote service, the root step of the service can be added to any trace step of the client). However, if a client spawns multiple services asynchronously and waits until all of them return, the isolated duration of the client step will return a meaningless value (since the overall processing time of the parallel services exceeds the execution time of the client step).

This class is only instantiated by implementations of ITraceSession

Author:
Gunther Popp
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.e2etrace.trace.AbstractTraceStep
children
 
Constructor Summary
TraceSessionRootStep(TraceSessionRootStepId id)
          Constructor.
 
Method Summary
 void enter()
          Enter the trace step and start time measuring.
 long getDuration()
          Returns the overall duration of this TraceStep and all children.
 long getIsolatedDuration()
          The isolated duration of the root step is by definition 0ms.
 boolean isActive()
          Checks, if the current trace step is active.
 void leave()
          Leave the trace step and calculate the elapsed time since enter has been called.
 
Methods inherited from class org.e2etrace.trace.AbstractTraceStep
addChild, equals, getChildren, getId, getParent, hashCode, leaveAllChildren, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TraceSessionRootStep

public TraceSessionRootStep(TraceSessionRootStepId id)
Constructor.

Parameters:
id - ID of the root step
Method Detail

getDuration

public long getDuration()
Returns the overall duration of this TraceStep and all children.

Specified by:
getDuration in interface ITraceStep
Specified by:
getDuration in class AbstractTraceStep
Returns:
duration in ms

getIsolatedDuration

public long getIsolatedDuration()
The isolated duration of the root step is by definition 0ms.

Specified by:
getIsolatedDuration in interface ITraceStep
Specified by:
getIsolatedDuration in class AbstractTraceStep
Returns:
duration of this TraceStep in ms (-1:leave has not been called yet)

enter

public void enter()
           throws IllegalStateException
Enter the trace step and start time measuring.

This method should only be called once for a trace step. All subsequent calls will be ignored.

Specified by:
enter in interface ITraceStep
Specified by:
enter in class AbstractTraceStep
Throws:
IllegalStateException

isActive

public boolean isActive()
Checks, if the current trace step is active.

The session root step is always active by definition.

Specified by:
isActive in interface ITraceStep
Specified by:
isActive in class AbstractTraceStep
Returns:
true

leave

public void leave()
           throws IllegalStateException
Leave the trace step and calculate the elapsed time since enter has been called. The elapsed time is returned by getDuration().

Leaving a step implies that all children are left, too.

This method should only be called once for a trace step. All subsequent calls will be ignored.

Specified by:
leave in interface ITraceStep
Specified by:
leave in class AbstractTraceStep
Throws:
IllegalStateException


Copyright © 2013 Gunther Popp. All Rights Reserved.