Package org.opensaml.profile.context
Class MetricContext
- java.lang.Object
-
- org.opensaml.messaging.context.BaseContext
-
- org.opensaml.profile.context.MetricContext
-
- All Implemented Interfaces:
Iterable<BaseContext>
public final class MetricContext extends BaseContext
Child context that supplies instructions to the runtime actions about timers to start and stop to measure performance.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opensaml.messaging.context.BaseContext
BaseContext.ContextSetNoRemoveIteratorDecorator
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,String>counterMapMap of objects to counter names.private Multimap<String,com.codahale.metrics.Timer.Context>timerContextMapMap of objects to contexts to perform a stop signal.private Multimap<String,Pair<String,String>>timerMapMap of objects to timer names to start and objects to stop the timer.
-
Constructor Summary
Constructors Constructor Description MetricContext()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MetricContextaddCounter(String counterName, String objectId)Add an object/counter mapping.MetricContextaddTimer(String timerName, String startId, String stopId)Add an object/timer mapping.voiddec(String objectId)Decrement a counter associated with an object, if any.Map<String,String>getCounterMappings()Get a modifiable map of object/counter associations.Collection<Pair<String,String>>getTimerMappings(String objectId)Get a modifiable collection of timer name / stop object pairs for the supplied start object ID.voidinc(String objectId)Increment a counter associated with an object, if any.voidstart(String objectId)Conditionally starts one or more timers based on the supplied object identifier.voidstop(String objectId)Stops any timers associated with the supplied object identifier and removes them from the tracking map.-
Methods inherited from class org.opensaml.messaging.context.BaseContext
addSubcontext, addSubcontext, clearSubcontexts, containsSubcontext, createSubcontext, getParent, getSubcontext, getSubcontext, getSubcontext, getSubcontext, iterator, removeSubcontext, removeSubcontext, setParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
timerMap
@Nonnull @NonnullElements private Multimap<String,Pair<String,String>> timerMap
Map of objects to timer names to start and objects to stop the timer.The first member is the timer name, the second the object to associate with the timer.
-
timerContextMap
@Nonnull @NonnullElements private Multimap<String,com.codahale.metrics.Timer.Context> timerContextMap
Map of objects to contexts to perform a stop signal.
-
counterMap
@Nonnull @NonnullElements private Map<String,String> counterMap
Map of objects to counter names.
-
-
Method Detail
-
addTimer
@Nonnull public MetricContext addTimer(@Nonnull @NotEmpty String timerName, @Nonnull @NotEmpty String startId, @Nonnull @NotEmpty String stopId)
Add an object/timer mapping.- Parameters:
timerName- name of timerstartId- ID of object to start timer withstopId- ID of object to stop timer- Returns:
- this context
-
getTimerMappings
@Nonnull @NonnullElements @Live public Collection<Pair<String,String>> getTimerMappings(@Nonnull @NotEmpty String objectId)
Get a modifiable collection of timer name / stop object pairs for the supplied start object ID.- Parameters:
objectId- the object ID input- Returns:
- the collection of associated mappings
-
addCounter
@Nonnull public MetricContext addCounter(@Nonnull @NotEmpty String counterName, @Nonnull @NotEmpty String objectId)
Add an object/counter mapping.- Parameters:
counterName- name of counterobjectId- object ID- Returns:
- this context
-
getCounterMappings
@Nonnull @NonnullElements @Live public Map<String,String> getCounterMappings()
Get a modifiable map of object/counter associations.- Returns:
- map of counters
-
start
public void start(@Nonnull @NotEmpty String objectId)
Conditionally starts one or more timers based on the supplied object identifier.The configured state of the context is used to determine whether, and which, timers to start, further influenced by the runtime state of the system with regard to enabling of metrics.
- Parameters:
objectId- ID of the object being timed
-
stop
public void stop(@Nonnull @NotEmpty String objectId)
Stops any timers associated with the supplied object identifier and removes them from the tracking map.- Parameters:
objectId- ID of the object being timed
-
inc
public void inc(@Nonnull @NotEmpty String objectId)
Increment a counter associated with an object, if any.- Parameters:
objectId- ID of object
-
-