com.threerings.presents.server
Class ReportingInvoker

java.lang.Object
  extended by java.lang.Thread
      extended by com.samskivert.util.LoopingThread
          extended by com.samskivert.util.Invoker
              extended by com.threerings.presents.server.ReportingInvoker
All Implemented Interfaces:
RunQueue, Runnable, Executor
Direct Known Subclasses:
PresentsAuthInvoker, PresentsInvoker

public class ReportingInvoker
extends Invoker

Extends invoker with a reporter implementation that shows current queue status, maximum historical size and the results of unit profiling if enabled.


Nested Class Summary
static class ReportingInvoker.Stats
           
 
Nested classes/interfaces inherited from class com.samskivert.util.Invoker
Invoker.Unit, Invoker.UnitProfile
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Nested classes/interfaces inherited from interface com.samskivert.util.RunQueue
RunQueue.AsExecutor
 
Field Summary
protected  ReportingInvoker.Stats _current
          Used to track runtime statistics.
protected  Object _currentUnit
          Records the currently invoking unit.
protected  long _currentUnitStart
          The time at which our current unit started.
protected  ReportManager.Reporter _defrep
          Generates a report on our runtime behavior.
protected  ReportManager.Reporter _profrep
          Generates a report with our profiling data.
protected  ReportingInvoker.Stats _recent
          Used to track runtime statistics.
protected  int _totalUnitsRun
          The total number of units run.
 
Fields inherited from class com.samskivert.util.Invoker
_defaultLongThreshold, _profileBucketCount, _profileBucketWidth, _queue, _receiver, _shutdownRequested, _tracker, PERF_TRACK
 
Fields inherited from class com.samskivert.util.LoopingThread
_running
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.samskivert.util.RunQueue
AWT
 
Constructor Summary
ReportingInvoker(String name, Executor receiver, ReportManager repmgr)
          Creates a new reporting invoker.
 
Method Summary
protected  void didInvokeUnit(Invoker.Unit unit, long start)
           
 ReportingInvoker.Stats getStats(boolean snapshot)
          Returns a recent snapshot of runtime statistics tracked by the invoker.
protected  void willInvokeUnit(Invoker.Unit unit, long start)
           
 
Methods inherited from class com.samskivert.util.Invoker
execute, getPendingUnits, isDispatchThread, iterate, postRunnable, postUnit, recordMetrics, setDefaultLongThreshold, setProfilingParameters, shutdown, shutdownRequested
 
Methods inherited from class com.samskivert.util.LoopingThread
didShutdown, handleIterateFailure, isRunning, kick, run, willStart
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.samskivert.util.RunQueue
isRunning
 

Field Detail

_defrep

protected ReportManager.Reporter _defrep
Generates a report on our runtime behavior.


_profrep

protected ReportManager.Reporter _profrep
Generates a report with our profiling data.


_recent

protected ReportingInvoker.Stats _recent
Used to track runtime statistics.


_current

protected ReportingInvoker.Stats _current
Used to track runtime statistics.


_totalUnitsRun

protected int _totalUnitsRun
The total number of units run.


_currentUnit

protected Object _currentUnit
Records the currently invoking unit.


_currentUnitStart

protected long _currentUnitStart
The time at which our current unit started.

Constructor Detail

ReportingInvoker

public ReportingInvoker(String name,
                        Executor receiver,
                        ReportManager repmgr)
Creates a new reporting invoker. The instance will be registered with the report manager if profiling is enabled (Invoker.PERF_TRACK).

Method Detail

getStats

public ReportingInvoker.Stats getStats(boolean snapshot)
Returns a recent snapshot of runtime statistics tracked by the invoker.

Parameters:
snapshot - if true, the current stats will be snapshotted and reset and the new snapshot will be returned. If false, the previous snapshot will be returned. If no snapshot has ever been taken, the current stats that have been accumulting since the JVM start will be returned.

willInvokeUnit

protected void willInvokeUnit(Invoker.Unit unit,
                              long start)
Overrides:
willInvokeUnit in class Invoker

didInvokeUnit

protected void didInvokeUnit(Invoker.Unit unit,
                             long start)
Overrides:
didInvokeUnit in class Invoker