|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.counters.AbstractCounterSet
com.bigdata.counters.CounterSet
public class CounterSet
A set of counters arranged in a hierarchy, much like a file system. Each node
has a name and a path. The name is a local and immutable label. The path is
the {separator, name} sequence reading down from the root to a given node.
The "root" is the top-most node in the hierarchy - it always has an empty
name and its path is /. The direct children of a root are
typically fully qualified host names. E.g., /www.bigdata.com.
Nodes are always created as children of an existing root. Once created, any
non-root node may be attached as a child of any other node, including a root
node, as long as cycles would not be formed. When a node is attached as a
child of another node, the path of the child and all of its children are
updated recursively. E.g., if /Memory is attached to
/www.bigdata.com then its path becomes
/www.bigdata.com/Memory.
Children are either CounterSets or individual Counters.
Counter sets and counters are declared in the namespace and their names must
be distinct.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.bigdata.counters.ICounterSet |
|---|
ICounterSet.IInstrumentFactory |
| Field Summary | |
|---|---|
protected static org.apache.log4j.Logger |
log
|
| Fields inherited from class com.bigdata.counters.AbstractCounterSet |
|---|
name, parent |
| Fields inherited from interface com.bigdata.counters.ICounterSet |
|---|
pathSeparator |
| Constructor Summary | |
|---|---|
CounterSet()
Ctor for a root node. |
|
| Method Summary | |
|---|---|
ICounter |
addCounter(String path,
IInstrument instrument)
Add a counter. |
void |
asXML(Writer w,
Pattern filter)
Per AbstractCounterSet.asXML(OutputStream, String, Pattern) but does not write out
the header declaring the encoding. |
void |
attach(ICounterNode src)
Attaches a CounterSet as a child of this node. |
void |
attach(ICounterNode src,
boolean replace)
|
Iterator<ICounter> |
counterIterator(Pattern filter)
Visits direct child counters matching the optional filter. |
Iterator<ICounterSet> |
counterSetIterator()
Iterator visits the directly attached ICounterSet children. |
ICounterNode |
detach(String path)
Detaches and returns the node having that path. |
Iterator |
directChildIterator(boolean sorted,
Class<? extends ICounterNode> type)
Iterator visits all directly attached children. |
ICounterNode |
getChild(String name)
Return the directly attached object by name. |
Iterator<ICounter> |
getCounters(Pattern filter)
Visits ICounter matching the optional filter declared anywhere in
the hierarchy spanned by this ICounterSet. |
Iterator<ICounterNode> |
getNodes(Pattern filter)
All spanned nodes. |
boolean |
isLeaf()
|
CounterSet |
makePath(String path)
Adds any necessary CounterSets described in the path (ala
mkdirs). |
Iterator |
postOrderIterator()
Iterator visits ICounterSet children recursively expanding each
child with a post-order traversal of its children and finally visits this
node itself. |
Iterator |
preOrderIterator()
Iterator visits this node recursively expanding each ICounterSet
child with a pre-order traversal of its children and finally visits this
node itself. |
void |
readXML(InputStream is,
ICounterSet.IInstrumentFactory instrumentFactory,
Pattern filter)
Reads counters into this hierarchy. |
| Methods inherited from class com.bigdata.counters.AbstractCounterSet |
|---|
asXML, asXML, asXML, getDepth, getName, getParent, getPath, getPath, getPathComponents, getRoot, isCounter, isCounterSet, isRoot, toString, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.bigdata.counters.ICounterSet |
|---|
asXML, asXML, toString, toString |
| Methods inherited from interface com.bigdata.counters.ICounterNode |
|---|
getDepth, getName, getParent, getPath, getPath, getRoot, isCounter, isCounterSet, isRoot |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
| Constructor Detail |
|---|
public CounterSet()
| Method Detail |
|---|
public boolean isLeaf()
public void attach(ICounterNode src)
CounterSet as a child of this node. If child
is a root, then all children of the child are attached instead.
If a CounterSet already exists then its children are attached. If
a Counters already exists then it is overwritten. During
recursive attach if we encounter a node that already exists then just
copy its children. If there is a conflict (trying to copy a counter over
a counter set or visa-versa), then a warning is logged and we ignore the
conflicting node.
src - The child counter set.
IllegalArgumentException - if child is null
IllegalStateException - if child is either this node or any parent of this
node since a cycle would be formed.
public void attach(ICounterNode src,
boolean replace)
public ICounterNode detach(String path)
path - The path.
null if there is no node with that
path.public Iterator<ICounter> counterIterator(Pattern filter)
Note: Since the filter does NOT have to be anchored at the root, the only place we can apply a filter that is NOT anchored at the root is when checking a fully qualified counter name.
ICounterSet.public Iterator<ICounterNode> getNodes(Pattern filter)
filter - An optional filter.
public Iterator<ICounter> getCounters(Pattern filter)
ICounterSetICounter matching the optional filter declared anywhere in
the hierarchy spanned by this ICounterSet.
getCounters in interface ICounterSetfilter - An optional regular expression that will be applied to
ICounterNode.getPath() to filter matches. When specified,
only ICounters whose ICounterNode.getPath() match
will be visited by the Iterator.
public Iterator directChildIterator(boolean sorted,
Class<? extends ICounterNode> type)
sorted - When true the children will be visited in order
by their name.type - An optional type filter - specify either ICounterSet
or ICounter you want to be visited by the iterator.
When null all directly attached children
(counters and counter sets) are visited.public Iterator<ICounterSet> counterSetIterator()
ICounterSet children.
public Iterator postOrderIterator()
ICounterSet children recursively expanding each
child with a post-order traversal of its children and finally visits this
node itself.
public Iterator preOrderIterator()
ICounterSet
child with a pre-order traversal of its children and finally visits this
node itself.
public ICounterNode getChild(String name)
ICounterNode
getChild in interface ICounterNodename - The counter name.
public CounterSet makePath(String path)
CounterSets described in the path (ala
mkdirs).
makePath in interface ICounterSetpath - The path.
CounterSet described by the path.
public ICounter addCounter(String path,
IInstrument instrument)
path - The path of the counter (absolute or relative).instrument - The object that is used to take the measurements from which
the counter's value will be determined.
public void asXML(Writer w,
Pattern filter)
throws IOException
AbstractCounterSet.asXML(OutputStream, String, Pattern) but does not write out
the header declaring the encoding.
asXML in interface ICounterSetw - The XML will be written on this object.filter - The optional filter.
IOException
public void readXML(InputStream is,
ICounterSet.IInstrumentFactory instrumentFactory,
Pattern filter)
throws IOException,
ParserConfigurationException,
SAXException
ICounterSet
readXML in interface ICounterSetinstrumentFactory - Used to create counters on an as needed basis.filter - An optional filter, when specified only counters matching the
filter will be processed.
IOException
ParserConfigurationException
SAXException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||