public class CounterSet extends AbstractCounterSet implements ICounterSet
/
. 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 CounterSet
s or individual Counter
s.
Counter sets and counters are declared in the namespace and their names must
be distinct.
ICounterSet.IInstrumentFactory
name, parent
pathSeparator
Constructor and Description |
---|
CounterSet()
Ctor for a root node.
|
Modifier and Type | Method and Description |
---|---|
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()
Return
true iff there are no children. |
CounterSet |
makePath(String path)
Adds any necessary
CounterSet s 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.
|
asXML, asXML, asXML, getDepth, getName, getParent, getPath, getPath, getPathComponents, getRoot, isCounter, isCounterSet, isRoot, toString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asXML, asXML, toString, toString
getDepth, getName, getParent, getPath, getPath, getRoot, isCounter, isCounterSet, isRoot
public boolean isLeaf()
true
iff there are no children.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 Counter
s 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.
public Iterator<ICounterNode> getNodes(Pattern filter)
filter
- An optional filter.public Iterator<ICounter> getCounters(Pattern filter)
ICounterSet
ICounter
matching the optional filter declared anywhere in
the hierarchy spanned by this ICounterSet
.getCounters
in interface ICounterSet
filter
- An optional regular expression that will be applied to
ICounterNode.getPath()
to filter matches. When specified,
only ICounter
s 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 ICounterNode
name
- The counter name.public CounterSet makePath(String path)
CounterSet
s described in the path (ala
mkdirs).makePath
in interface ICounterSet
path
- 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 ICounterSet
w
- 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 ICounterSet
instrumentFactory
- 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
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.