Class Observer<T extends Metrics>

java.lang.Object
com.zeroc.IceMX.Observer<T>
Type Parameters:
T - the metrics type
All Implemented Interfaces:
Observer
Direct Known Subclasses:
ObserverWithDelegate

public class Observer<T extends Metrics> extends Object implements Observer
Observer implementation for metrics collection.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Interface for updating metrics objects.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method is called when the instrumented object is created or when the observer is attached to an existing object.
    long
    Gets the current elapsed time without stopping the stopwatch.
    void
    This method is called when the instrumented object is destroyed and as a result the observer detached from the object.
    void
    failed(String exceptionName)
    Notification of a failure.
    void
    Executes the specified update function on all metrics objects.
    com.zeroc.Ice.MetricsMap<T>.Entry
    getEntry(com.zeroc.Ice.MetricsMap<?> map)
    Gets the metrics map entry for the specified map.
    <S extends Metrics, ObserverImpl extends Observer<S>>
    ObserverImpl
    getObserver(String mapName, MetricsHelper<S> helper, Class<S> mcl, Class<ObserverImpl> ocl)
    Gets a sub-observer for the specified metrics type.
    void
    init(MetricsHelper<T> helper, List<com.zeroc.Ice.MetricsMap<T>.Entry> objects, Observer<T> previous)
    Initializes this observer with the specified parameters.
    boolean
    Checks whether the stopwatch is currently running.
    void
    Starts the stopwatch.
    long
    Stops the stopwatch and returns the elapsed time.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Observer

      public Observer()
  • Method Details

    • attach

      public void attach()
      Description copied from interface: Observer
      This method is called when the instrumented object is created or when the observer is attached to an existing object.
      Specified by:
      attach in interface Observer
    • detach

      public void detach()
      Description copied from interface: Observer
      This method is called when the instrumented object is destroyed and as a result the observer detached from the object.
      Specified by:
      detach in interface Observer
    • failed

      public void failed(String exceptionName)
      Description copied from interface: Observer
      Notification of a failure.
      Specified by:
      failed in interface Observer
      Parameters:
      exceptionName - The name of the exception.
    • forEach

      public void forEach(Observer.MetricsUpdate<T> u)
      Executes the specified update function on all metrics objects.
      Parameters:
      u - the update function to execute
    • init

      public void init(MetricsHelper<T> helper, List<com.zeroc.Ice.MetricsMap<T>.Entry> objects, Observer<T> previous)
      Initializes this observer with the specified parameters.
      Parameters:
      helper - the metrics helper
      objects - the list of metrics map entries
      previous - the previous observer, or null
    • getObserver

      public <S extends Metrics, ObserverImpl extends Observer<S>> ObserverImpl getObserver(String mapName, MetricsHelper<S> helper, Class<S> mcl, Class<ObserverImpl> ocl)
      Gets a sub-observer for the specified metrics type.
      Type Parameters:
      S - the sub-metrics type
      ObserverImpl - the observer implementation type
      Parameters:
      mapName - the name of the metrics map
      helper - the metrics helper for the sub-metrics type
      mcl - the metrics class
      ocl - the observer class
      Returns:
      the sub-observer, or null if no matching entries are found
    • getEntry

      public com.zeroc.Ice.MetricsMap<T>.Entry getEntry(com.zeroc.Ice.MetricsMap<?> map)
      Gets the metrics map entry for the specified map.
      Parameters:
      map - the metrics map to find
      Returns:
      the matching entry, or null if not found
    • start

      public void start()
      Starts the stopwatch.
    • stop

      public long stop()
      Stops the stopwatch and returns the elapsed time.
      Returns:
      the elapsed time in microseconds
    • isStarted

      public boolean isStarted()
      Checks whether the stopwatch is currently running.
      Returns:
      true if the stopwatch is started, false otherwise
    • delay

      public long delay()
      Gets the current elapsed time without stopping the stopwatch.
      Returns:
      the elapsed time in microseconds since start was called