|
Oracle Application Server DMS API Reference 10g Release 2 (10.1.2) B14002-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.dms.instrument.Sensor
oracle.dms.instrument.State
A State
Sensor can be used to monitor pre-computed metric values. A State can be used to monitor arbitrary values, including integers, doubles, longs, or Object references. Use a State Sensor to represent status or gauge values that may increase or decrease during JVM execution. For example, queue lengths, pool sizes, buffer sizes, configuration parameters, etc. Depending on the derived metrics specified, a State sensor may contain value
and count
metrics. Numeric States may also contain Sensor.maximum
and Sensor.minimum
derived metrics. The following code segment provides an example of how one would typically create and use a State sensor to monitor the length of a queue.
Assume the existence of parent Noun named "/queue":
State queueState = State.create(parent, "length", State.INTEGER,
<spacer type="horizontal" size="190"> "items", "length of queue");
queueState.deriveMetric(Sensor.maximum);
queueState.update(0); // set initial value to 0
Alternatively, this State Sensor could be created using the path name of the Sensor:
State.create("/queue/length", State.INTEGER,
<spacer type="horizontal" size="190"> "items", "length of queue");
The call to
queueState.deriveMetric(Sensor.maximum);
will cause the maximum items on the queue at any time to be tracked and reported if the State is properly updated when items are added to and removed from the queue. Later, in a method that adds an item to a queue, one should call
queueState.increment(1);
to account for it. When an item is later removed from the queue, it can be propertly tracked using:
queueState.increment(-1);
For a state containing a value that should be set directly, one of the update()
calls would be used rather than increment()
.
Field Summary | |
static byte |
DOUBLE Data type for State is the Java primitive double |
static byte |
INTEGER Data type for State is the Java primitive int |
static byte |
LONG Data type for State is the Java primitive long |
static byte |
OBJECT Data type for State is java.lang.Object |
Fields inherited from class oracle.dms.instrument.Sensor |
active, all, average, completed, count, exclTime, maxActive, maximum, minimum, sum, time, value |
Method Summary | |
static State |
create(Noun parent, java.lang.String name, byte valueType, java.lang.String units, java.lang.String desc) Creates an uninitialized State Sensor. |
static State |
create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, double init) Deprecated. As of Oracle AS 10.1.2, replaced by create(Noun, String, byte, String, String) |
static State |
create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, int init) Deprecated. As of Oracle AS 10.1.2, replaced by create(Noun, String, byte, String, String) |
static State |
create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, long init) Deprecated. As of Oracle AS 10.1.2, replaced by create(Noun, String, byte, String, String) |
static State |
create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, java.lang.Object init) Deprecated. As of Oracle AS 10.1.2, replaced by create(Noun, String, byte, String, String) |
void |
deriveMetric(int metric) Derives additional metrics for the State. |
byte |
getValueType() Get the type of data maintained in this object. |
void |
increment(double inc) Adds to the value of the State. |
void |
increment(int inc) Adds to the value of the State. |
void |
increment(long inc) Adds to the value of the State. |
void |
setCopy(boolean copy) Set the State to store a String copy of the maintained object. |
void |
update(double newval) Updates the value of the State. |
void |
update(int newval) Updates the value of the State. |
void |
update(long newval) Updates the value of the State. |
void |
update(java.lang.Object newval) Updates the value of the State. |
Methods inherited from class oracle.dms.instrument.Sensor |
destroy, get, getDescription, getName, getValue, reset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final byte DOUBLE
public static final byte LONG
public static final byte INTEGER
public static final byte OBJECT
Method Detail |
public static State create(Noun parent, java.lang.String name, byte valueType, java.lang.String units, java.lang.String desc)
State.update()
. The type of data to be maintained in the State is specified in the valueType
parameter, and cannot be changed.
If State.OBJECT is specified, a reference to any Java object can be maintained in the State. If a call is made to setCopy(boolean)
, a String copy (using the object's toString()
method) will be maintained, rather than a reference to the object.
parent
- the noun the State should be created undername
- the name of the StatevalueType
- the type of data to be maintained in this State, which must be one of DOUBLE
, LONG
, INTEGER
, or OBJECT
.units
- the label for the units of the value.desc
- a description for the State.InstrumentationException
- if the parameters are invalid.public static State create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, int init)
create(Noun, String, byte, String, String)
Integer
.parent
- the State's parent Noun.name
- the name of the State.units
- the label for the units of the value.desc
- a description for the State.init
- initial State valuepublic static State create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, long init)
create(Noun, String, byte, String, String)
Long
.parent
- the State's parent Noun.name
- the name of the State.units
- the label for the units of the value.desc
- a description for the State.init
- initial State valuepublic static State create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, double init)
create(Noun, String, byte, String, String)
Double
.parent
- the State's parent Noun.name
- the name of the State.units
- the label for the units of the value.desc
- a description for the State.init
- initial State valuepublic static State create(Noun parent, java.lang.String name, java.lang.String units, java.lang.String desc, java.lang.Object init)
create(Noun, String, byte, String, String)
parent
- the State's parent Noun.name
- the name of the State.units
- the label for the units of the value.desc
- a description for the State.init
- initial State value
DMS stores a reference to the Object, not a copy of the Object. The metric value may change, if the Object is modified. When reporting the State's metric value, DMS will call toString()
on the Object.
public void deriveMetric(int metric)
deriveMetric
in class Sensor
metric
- a bitmask indicating the metric(s) to derive.
Possible values are Sensor.minimum
, Sensor.maximum
, and Sensor.count
. The values can be bitwise-ORed together, or multiple calls to deriveMetric can be made at the programmer's convenience. Sensor.minimum
and Sensor.maximum
are not applicable to non-numeric States.
public void update(int newval)
Integer
.newval
- the new value for the State.public void update(long newval)
Long
.newval
- the new value for the State.public void update(double newval)
Double
.newval
- the new value for the State.public void update(java.lang.Object newval)
newval
- the new value for the State.
DMS stores a reference to the input Object, not a copy. The metric value may change, if the Object is modified. When reporting the State's metric value, DMS will call toString()
on the Object.
public void increment(int inc)
Integer
. To decrement, just pass in a negative value.inc
- the new value to add to the current value of the State.java.lang.ClassCastException
- if the previous State value was not a Number.public void increment(long inc)
Long
. To decrement, just pass in a negative value.inc
- the new value to add to the current value of the State.java.lang.ClassCastException
- if the previous State value was not a Number.public void increment(double inc)
Double
. To decrement, just pass in a negative value.inc
- the new value to add to the current value of the State.java.lang.ClassCastException
- if the previous State value was not a Number.public byte getValueType()
public void setCopy(boolean copy)
OBJECT
normally maintains a reference to the object it has last been updated with. When the value is retrieved for reporting, it is converted to a String using toString() on the object reference. An input value of true will cause the State to maintain object.toString() rather than a reference object. Further changes to the object will not impact the contents of the state after setCopy() is called with true. This method has no impact unless the State type is OBJECT.copy
- whether to store a String copy or the object reference.
|
Oracle Application Server DMS API Reference 10g Release 2 (10.1.2) B14002-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |