public abstract class AbstractStatisticsCollector extends Object implements IStatisticsCollector
ICounterSet
s and ICounter
s. A
minimum set of counters
is defined which SHOULD
be available for decision-making. Implementations are free to report any
additional data which they can make available. Reporting is assumed to be
periodic, e.g., every 60 seconds or so. The purpose of these data is to
support decision-making concerning the over- and under-utilization of hosts
in support of load balancing of services deployed over those hosts.
An effort has been made to align the core set of counters for both Windows and Un*x platforms so as to support the declared counters on all platforms.
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractStatisticsCollector.Options
Options for
AbstractStatisticsCollector |
Modifier and Type | Field and Description |
---|---|
static String |
fullyQualifiedHostName
InetAddress.getCanonicalHostName() for this host. |
static String |
hostPathPrefix
The path prefix under which all counters for this host are found.
|
protected int |
interval
Reporting interval in seconds.
|
protected static org.apache.log4j.Logger |
log |
protected static String |
ps |
Modifier | Constructor and Description |
---|---|
protected |
AbstractStatisticsCollector(int interval,
String processName) |
Modifier and Type | Method and Description |
---|---|
static void |
addBasicServiceOrClientCounters(CounterSet serviceRoot,
String serviceName,
Class serviceIface,
Properties properties)
Adds the Info and Memory counter sets under the serviceRoot.
|
static void |
addGarbageCollectorMXBeanCounters(CounterSet counterSet)
Adds/updates counters relating to JVM Garbage Collection.
|
static void |
addMemoryPoolMXBeanCounters(CounterSet counterSet)
Adds/updates counters relating to JVM Memory Pools.
|
static void |
addServiceProperties(CounterSet serviceInfoSet,
Properties properties)
Lists out all of the properties and then report each property using a
OneShotInstrument . |
CounterSet |
getCounters()
Return the counter hierarchy.
|
int |
getInterval()
The interval in seconds at which the counter values are read from the
host platform.
|
static CounterSet |
getMemoryCounterSet()
Return the
memory counter set . |
String |
getProcessName()
The name of the process (or more typically its service
UUID )
whose per-process performance counters are to be collected. |
protected void |
installShutdownHook()
Installs a
Runtime.addShutdownHook(Thread) that executes
stop() . |
static Double |
kb2b(String kb)
Converts KB to bytes.
|
static void |
main(String[] args)
Utility runs the
AbstractStatisticsCollector appropriate for your
operating system. |
static AbstractStatisticsCollector |
newInstance(Properties properties)
Create an instance appropriate for the operating system on which the JVM
is running.
|
void |
start()
Start collecting host performance data -- must be extended by the
concrete subclass.
|
void |
stop()
Stop collecting host performance data -- must be extended by the concrete
subclass.
|
protected static final String ps
protected static final org.apache.log4j.Logger log
public static final String fullyQualifiedHostName
InetAddress.getCanonicalHostName()
for this host.public static final String hostPathPrefix
protected final int interval
protected AbstractStatisticsCollector(int interval, String processName)
public int getInterval()
getInterval
in interface IStatisticsCollector
public String getProcessName()
UUID
)
whose per-process performance counters are to be collected.public CounterSet getCounters()
AbstractProcessCollector
.
Note: Subclasses MUST extend this method to initialize their own
counters.
TODO Why does this use the older synchronized
pattern with a
shared countersRoot
object rather than returning a new object
per request? Check assumptions in the scale-out and local journal code
bases for this.
getCounters
in interface ICounterSetAccess
public static void addBasicServiceOrClientCounters(CounterSet serviceRoot, String serviceName, Class serviceIface, Properties properties)
serviceRoot
- The CounterSet
corresponding to the service (or
client).serviceName
- The name of the service.serviceIface
- The class or interface that best represents the service or
client.properties
- The properties used to configure that service or client.public static CounterSet getMemoryCounterSet()
memory counter set
. This
should be attached to the service root.public static void addServiceProperties(CounterSet serviceInfoSet, Properties properties)
OneShotInstrument
.serviceInfoSet
- The ICounterHierarchy.Info
CounterSet
for the
service.properties
- The properties to be reported out.public static void addGarbageCollectorMXBeanCounters(CounterSet counterSet)
counterSet
- The counters set that is the direct parent.public static void addMemoryPoolMXBeanCounters(CounterSet counterSet)
counterSet
- The counters set that is the direct parent.public void start()
start
in interface IStatisticsCollector
public void stop()
stop
in interface IStatisticsCollector
protected void installShutdownHook()
Runtime.addShutdownHook(Thread)
that executes
stop()
.
Note: The runtime shutdown hook appears to be a robust way to handle ^C by providing a clean service termination. However, under eclipse (at least when running under Windows) you may find that the shutdown hook does not run when you terminate a Java application and that typedef process build up in the Task Manager as a result. This should not be the case during normal deployment.
public static AbstractStatisticsCollector newInstance(Properties properties)
properties
- See AbstractStatisticsCollector.Options
UnsupportedOperationException
- If there is no implementation available on the operating
system on which you are running.AbstractStatisticsCollector.Options
public static void main(String[] args) throws InterruptedException
AbstractStatisticsCollector
appropriate for your
operating system. Before performance counter collection starts the static
counters will be written on stdout. The appropriate process(es) are then
started to collect the dynamic performance counters. Collection will
occur every AbstractStatisticsCollector.Options.PERFORMANCE_COUNTERS_SAMPLE_INTERVAL
seconds.
The program will make 10 collections by default and will write the
updated counters on stdout every
AbstractStatisticsCollector.Options.PERFORMANCE_COUNTERS_SAMPLE_INTERVAL
seconds.
Parameters also may be specified using -D
. See
AbstractStatisticsCollector.Options
.
args
- [interval [count]]
interval is the collection interval in seconds and
defaults to
AbstractStatisticsCollector.Options.DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL
.
count is the #of collections to be made and defaults
to 10
. Specify zero (0) to run until halted.
InterruptedException
RuntimeException
- if the arguments are not valid.UnsupportedOperationException
- if no implementation is available for your operating system.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.