jrunx.metrics
Interface Metrics

All Superinterfaces:
MetricsConstants, MetricsServiceMBean, java.io.Serializable, Service, ServiceMBean
All Known Implementing Classes:
MetricsService

public interface Metrics
extends MetricsServiceMBean, MetricsConstants

Metrics container interface. Numeric metrics for the server are kept in this container.


Fields inherited from interface jrunx.kernel.Service
INITIALIZED, STARTED, STARTING, STOPPED, STOPPING, UNINITIALIZED
 
Fields inherited from interface jrunx.metrics.MetricsConstants
METRICS_BUSY_TH, METRICS_DELAY_MS, METRICS_DELAY_RQ, METRICS_DELAY_TH, METRICS_DROPPED_RQ, METRICS_FREE_MEMORY, METRICS_IDLE_TH, METRICS_LISTEN_TH, METRICS_TOTAL_MEMORY, METRICS_TOTAL_TH
 
Method Summary
 int createMetric(java.lang.String name)
          create a metric with the given name
 int createMetric(java.lang.String name, boolean reset)
          create a metric with the given name.
 java.util.Properties createProperties(int[] values)
          Create a Properties object with the metrics name as the key and the given values as the corresponding element.
 void deleteMetric(java.lang.String name)
          remove a metric by name
 int[] exchangeMetrics(int[] values)
          swap metrics arrays atomically.
 int findMetric(java.lang.String name)
          look up a metric by name
 int getMetric(int index)
          obtain the value of a metric
 int[] getSnapshot()
          Take a snapshot of the current metrics.
 int[] getSnapshot(boolean reset)
          Take a snapshot of the current metrics.
 java.util.Vector getSnapshotHistory()
          Returns the snapshot history.
 long getSnapshotTime()
          Returns the timestamp of the last snapshot.
 boolean isReset(java.lang.String name)
          Determine if the metric should be reset when a snapshot is taken
 void setMetric(int index, int value)
          change the value of a metric
 int updateMetric(int index, int delta)
          update the value of a metric by adding the given delta value in an atomic operation.
 
Methods inherited from interface jrunx.metrics.MetricsServiceMBean
getHistorySize, getInitialSize, getMetricsService, setHistorySize, setInitialSize
 
Methods inherited from interface jrunx.kernel.ServiceMBean
bind, getBindToJNDI, getDeactivated, getDomainName, getJRunService, getLogger, getName, getParentService, getServerName, requestServer, setBindToJNDI, setDeactivated, setDomainName, setName, setParentService, unbind
 
Methods inherited from interface jrunx.kernel.Service
destroy, getStatus, init, start, stop, updateStatus
 

Method Detail

createMetric

public int createMetric(java.lang.String name)
create a metric with the given name
Parameters:
the - name of the metric
Returns:
index of the new metric

createMetric

public int createMetric(java.lang.String name,
                        boolean reset)
create a metric with the given name. If the 'reset' value is true then the value will be reset after logging
Parameters:
name - the name of the metric
reset - true if the value should be reset after logging
Returns:
index of the new metric

setMetric

public void setMetric(int index,
                      int value)
change the value of a metric
Parameters:
index - metric to be updated
value - the new value

getMetric

public int getMetric(int index)
obtain the value of a metric
Parameters:
index - metric to be fetched

updateMetric

public int updateMetric(int index,
                        int delta)
update the value of a metric by adding the given delta value in an atomic operation.
Parameters:
index - the metric index
Returns:
the new metric value, equal to [old-value] + delta

findMetric

public int findMetric(java.lang.String name)
look up a metric by name
Parameters:
the - name
Returns:
the index of the metric, or -1 if not found

deleteMetric

public void deleteMetric(java.lang.String name)
remove a metric by name
Parameters:
name - String name of the metric to be deleted

exchangeMetrics

public int[] exchangeMetrics(int[] values)
swap metrics arrays atomically. This method can be used to efficiently take a snapshot of the current metrics. A separate entity can maintain a set of buffers and rotate them in and out of the metrics manager.
Parameters:
values - an old buffer to install
Returns:
the current buffer with the latest values

getSnapshot

public int[] getSnapshot()
Take a snapshot of the current metrics.
Returns:
The current metrics

getSnapshot

public int[] getSnapshot(boolean reset)
Take a snapshot of the current metrics. Optionally reset any metrics that should be reset (reset flag true on createMetric).
Parameters:
reset - true if the metrics should be reset
Returns:
The current metrics

getSnapshotTime

public long getSnapshotTime()
Returns the timestamp of the last snapshot. This can be used to determine the current elapsed time of the metrics that are reset
Returns:
The last time a snapshot (and reset) was performed

getSnapshotHistory

public java.util.Vector getSnapshotHistory()
Returns the snapshot history. The history is returned as a Vector of MetricsSnapshot objects, with the first element being the most recent and the last element being the oldest.
Returns:
The vector of MetricsSnapshot objects

createProperties

public java.util.Properties createProperties(int[] values)
Create a Properties object with the metrics name as the key and the given values as the corresponding element.
Parameters:
The - values
Returns:
The Properties object

isReset

public boolean isReset(java.lang.String name)
Determine if the metric should be reset when a snapshot is taken
Parameters:
name - The metric name
Returns:
true if the metric should be reset


Copyright � 2002 Macromedia Corporation. All Rights Reserved.