public abstract class AbstractCounterSet extends Object implements ICounterSet
ICounterSet.IInstrumentFactory
Modifier and Type | Field and Description |
---|---|
protected String |
name |
protected AbstractCounterSet |
parent |
pathSeparator
Modifier | Constructor and Description |
---|---|
protected |
AbstractCounterSet(String name,
CounterSet parent) |
Modifier and Type | Method and Description |
---|---|
void |
asXML(OutputStream os,
String encoding,
Pattern filter)
Uses a post-order iteration to visit the
CounterSet s and for
each CounterSet writes the current value of each Counter . |
String |
asXML(Pattern filter)
Writes out the
ICounterSet as XML on a string and returns that
string. |
void |
asXML(Writer w,
String encoding,
Pattern filter)
Alternative, but you are still required to specify the character set
encoding in use by the writer.
|
int |
getDepth()
Depth of this node in the hierarchy, where the depth of the root is ZERO
(0).
|
String |
getName()
The local name (does not include the path from the root).
|
ICounterSet |
getParent()
The immediate parent in the hierarchy -or-
null iff this
is the root of the hierarchy. |
String |
getPath()
Complete path from the root inclusive of the local name.
|
ICounterNode |
getPath(String path)
Return the object described by the path.
|
ICounterSet[] |
getPathComponents()
The ordered array of counter sets from the root.
|
AbstractCounterSet |
getRoot()
The root of the hierarchy.
|
boolean |
isCounter()
true iff this is a counter. |
boolean |
isCounterSet()
true iff this is a collection of counters. |
boolean |
isRoot()
true iff this is the root of the hierarchy. |
String |
toString()
A human readable representation of all counters in the hierarchy together
with their current value.
|
String |
toString(Pattern filter)
A human readable representation of the counters in the hierarchy together
with their current value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asXML, getCounters, makePath, readXML
getChild
protected final String name
protected AbstractCounterSet parent
protected AbstractCounterSet(String name, CounterSet parent)
public AbstractCounterSet getRoot()
ICounterNode
getRoot
in interface ICounterNode
public String getName()
ICounterNode
getName
in interface ICounterNode
public ICounterSet[] getPathComponents()
public String getPath()
ICounterNode
getPath
in interface ICounterNode
public int getDepth()
ICounterNode
getDepth
in interface ICounterNode
public ICounterNode getPath(String path)
ICounterNode
getPath
in interface ICounterNode
path
- The path.null
if nothing exists for that
path.public ICounterSet getParent()
ICounterNode
null
iff this
is the root of the hierarchy.getParent
in interface ICounterNode
public boolean isRoot()
ICounterNode
true
iff this is the root of the hierarchy.isRoot
in interface ICounterNode
public String toString()
ICounterSet
toString
in interface ICounterSet
toString
in class Object
public String toString(Pattern filter)
ICounterSet
toString
in interface ICounterSet
filter
- An optional filter that will be used to select only specific
counters.public final boolean isCounterSet()
ICounterNode
true
iff this is a collection of counters.isCounterSet
in interface ICounterNode
public final boolean isCounter()
ICounterNode
true
iff this is a counter.isCounter
in interface ICounterNode
public void asXML(OutputStream os, String encoding, Pattern filter) throws IOException
CounterSet
s and for
each CounterSet
writes the current value of each Counter
.
A sample output is below.
cs
is a CounterSet
element and has a
path
attribute which expresses the location of the counter
set within the hierarchy (counter set elements are not nested inside of
each other in the XML serialization). Only counter sets with counters are
emitted.
c
is a Counter
element and is nested inside of the
corresponding counter set. Each counter carries a name
attribute, a simple XML Schema Datatype, a timestamp (milliseconds since
the epoch per System.currentTimeMillis()
, and has a counter
value which is the inner content of the c
element.
<?xml version="1.0" encoding="UTF-8"?> <counters xmlns:xs="http://www.w3.org/2001/XMLSchema"> <cs path="/www.bigdata.com/cpu"> <c name="availableProcessors" type="xs:int" time="1205928108602">2</c> </cs> <cs path="/www.bigdata.com/memory"> <c name="maxMemory" type="xs:long" time="1205928108602">517013504</c> </cs> <cs path="/"> <c name="elapsed" type="xs:long" time="1205928108602">1205928108602</c> </cs> </counters>
asXML
in interface ICounterSet
os
- The sink on which the representation will be written.encoding
- The character set encoding that will be used, e.g.,
UTF-8
.filter
- An optional filter that will be used to select only specific
counters.IOException
public void asXML(Writer w, String encoding, Pattern filter) throws IOException
w
- The writer.encoding
- The character set encoding used by that writer.filter
- An optional filter.IOException
public String asXML(Pattern filter)
ICounterSet
ICounterSet
as XML on a string and returns that
string.asXML
in interface ICounterSet
filter
- An optional filter.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.