public class OpRegistry extends Object
OpCounter's that are in some way related.
It can create new OpCounter objects directly via is pull() methods. This makes it easier to manage the creation of performance statistics.
Its just a fraction easier to use than a raw map plus is has thread safety.
| Constructor and Description |
|---|
OpRegistry() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(List<OpSnapshot> opSnapshotList)
This will "pull" a List of OpSnapshot objects into the current registry
|
OpCounter |
add(OpCounter srcOpCounter)
This will "pull" a counter into the registry and add the value of the OpCounter to it.
|
void |
add(OpRegistry srcOpRegistry)
This will "pull" all the counters out of the passed in OpRegistry and add the values to counters under the same
names in the current registry.
|
OpCounter |
add(OpSnapshot srcOpSnapshot)
This will "pull" a counter into the registry and add the value of the OpCounter to it.
|
OpCounter |
get(String opName)
Returns the OpCounter under the specified name or null if its not present.
|
OpCounter |
pull(String opName)
This is a pull through operation that guarantees to ATOMICALLy create an OpCounter under the name if its not
present OR return the previously created one if its there.
|
OpTimer |
pullTimer(String name)
Call this method to start an OpTimer.
|
OpCounter |
put(OpCounter opCounter)
Can be called to PUT a counter into the registry.
|
List<OpSnapshot> |
snapshot()
This returns a List of OpSnapshot objects that represent the values of the all the OpCounter's in the OpRegistry
at the time the method was called.
|
List<OpSnapshot> |
snapshotAndClear()
This returns a List of OpSnapshot objects that represent the values of the all the OpCounter's in the OpRegistry
at the time the method was called and then clears the internal list of counters.
|
String |
toString() |
public OpCounter put(OpCounter opCounter)
THREAD-SAFE - Uses ConcurrentHashMap under the covers
opCounter - the counter in question - It must NOT be nullpublic OpCounter get(String opName)
THREAD-SAFE - Uses ConcurrentHashMap under the covers
opName - the name of the counter to retrieve. It must not be null.public OpTimer pullTimer(String name)
OpTimer timer = registry.pullTimer("opName");
...
... // do some work
...
timer.end();
//
// the timer values will now be pulled into the
// registry under the name "opName"
name - the name of the operationpublic OpCounter pull(String opName)
THREAD-SAFE - Uses ConcurrentHashMap under the covers
opName - the name of the operationpublic OpCounter add(OpCounter srcOpCounter)
srcOpCounter - the source OpCounter to get values from topublic OpCounter add(OpSnapshot srcOpSnapshot)
srcOpSnapshot - the source OpSnapshot to get values from topublic void add(OpRegistry srcOpRegistry)
THREAD-SAFETY - Since the srcOpRegistry is mutable, it can only get a snapshot of the other registry at a point in time.
srcOpRegistry - the registry to copy values frompublic void add(List<OpSnapshot> opSnapshotList)
opSnapshotList - a List of OpSnapshot objectspublic List<OpSnapshot> snapshot()
The list is MUTABLE and a copy of the OpCounter values. So feel free to mutate it by sorting it and filtering it.
public List<OpSnapshot> snapshotAndClear()
The list is MUTABLE and a copy of the OpCounter values. So feel free to mutate it by sorting it and filtering it.
Copyright © 2016 Atlassian. All rights reserved.