org.apache.oozie.util
Class Instrumentation

java.lang.Object
  extended by org.apache.oozie.util.Instrumentation

public class Instrumentation
extends Object

Instrumentation framework that supports Timers, Counters, Variables and Sampler instrumentation elements.

All instrumentation elements have a group and a name.


Nested Class Summary
static class Instrumentation.Cron
          Cron is a stopwatch that can be started/stopped several times.
static interface Instrumentation.Element<T>
          Gives access to a snapshot of an Instrumentation element (Counter, Timer).
static class Instrumentation.Timer
          Timer Instrumentation element.
static interface Instrumentation.Variable<T>
          Interface for instrumentation variables.
 
Constructor Summary
Instrumentation()
          Instrumentation constructor.
 
Method Summary
 void addCron(String group, String name, Instrumentation.Cron cron)
          Add a cron to an instrumentation timer.
 void addSampler(String group, String name, int period, int interval, Instrumentation.Variable<Long> variable)
          Add a sampling variable.
 void addVariable(String group, String name, Instrumentation.Variable variable)
          Add an instrumentation variable.
 Map<String,Map<String,Map<String,Object>>> getAll()
          Return a map containing all variables, counters and timers.
 Map<String,String> getConfiguration()
          Return the current system configuration as a Map.
 Map<String,Map<String,Instrumentation.Element<Long>>> getCounters()
          Return all the counters.
 Map<String,String> getJavaSystemProperties()
          Return the JVM system properties.
 Map<String,String> getOSEnv()
          Return the OS environment used to start Oozie.
 Map<String,Map<String,Instrumentation.Element<Double>>> getSamplers()
          Return all the samplers.
 Map<String,Map<String,Instrumentation.Element<Instrumentation.Timer>>> getTimers()
          Return all the timers.
 Map<String,Map<String,Instrumentation.Element<Instrumentation.Variable>>> getVariables()
          Return all the variables.
 void incr(String group, String name, long count)
          Increment an instrumentation counter.
 void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
          Set the system configuration.
 void setScheduler(ScheduledExecutorService scheduler)
          Set the scheduler instance to handle the samplers.
 String toString()
          Return the string representation of the instrumentation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Instrumentation

public Instrumentation()
Instrumentation constructor.

Method Detail

setScheduler

public void setScheduler(ScheduledExecutorService scheduler)
Set the scheduler instance to handle the samplers.

Parameters:
scheduler - scheduler instance.

addCron

public void addCron(String group,
                    String name,
                    Instrumentation.Cron cron)
Add a cron to an instrumentation timer. The timer is created if it does not exists.

This method is thread safe.

Parameters:
group - timer group.
name - timer name.
cron - cron to add to the timer.

incr

public void incr(String group,
                 String name,
                 long count)
Increment an instrumentation counter. The counter is created if it does not exists.

This method is thread safe.

Parameters:
group - counter group.
name - counter name.
count - increment to add to the counter.

addVariable

public void addVariable(String group,
                        String name,
                        Instrumentation.Variable variable)
Add an instrumentation variable. The variable must not exist.

This method is thread safe.

Parameters:
group - counter group.
name - counter name.
variable - variable to add.

setConfiguration

public void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
Set the system configuration.

Parameters:
configuration - system configuration.

getJavaSystemProperties

public Map<String,String> getJavaSystemProperties()
Return the JVM system properties.

Returns:
JVM system properties.

getOSEnv

public Map<String,String> getOSEnv()
Return the OS environment used to start Oozie.

Returns:
the OS environment used to start Oozie.

getConfiguration

public Map<String,String> getConfiguration()
Return the current system configuration as a Map.

Returns:
the current system configuration as a Map.

getCounters

public Map<String,Map<String,Instrumentation.Element<Long>>> getCounters()
Return all the counters.

This method is thread safe.

The counters are live. The counter value is a snapshot at the time the Instrumentation.Element.getValue() is invoked.

Returns:
all counters.

getTimers

public Map<String,Map<String,Instrumentation.Element<Instrumentation.Timer>>> getTimers()
Return all the timers.

This method is thread safe.

The timers are live. Once a timer is obtained, all its values are consistent (they are snapshot at the time the Instrumentation.Element.getValue() is invoked.

Returns:
all counters.

getVariables

public Map<String,Map<String,Instrumentation.Element<Instrumentation.Variable>>> getVariables()
Return all the variables.

This method is thread safe.

The variables are live. The variable value is a snapshot at the time the Instrumentation.Element.getValue() is invoked.

Returns:
all counters.

getAll

public Map<String,Map<String,Map<String,Object>>> getAll()
Return a map containing all variables, counters and timers.

Returns:
a map containing all variables, counters and timers.

toString

public String toString()
Return the string representation of the instrumentation.

Overrides:
toString in class Object
Returns:
the string representation of the instrumentation.

addSampler

public void addSampler(String group,
                       String name,
                       int period,
                       int interval,
                       Instrumentation.Variable<Long> variable)
Add a sampling variable.

This method is thread safe.

Parameters:
group - timer group.
name - timer name.
period - sampling period to compute rate.
interval - sampling frequency, how often the variable is probed.
variable - variable to sample.

getSamplers

public Map<String,Map<String,Instrumentation.Element<Double>>> getSamplers()
Return all the samplers.

This method is thread safe.

The samplers are live. The sampler value is a snapshot at the time the Instrumentation.Element.getValue() is invoked.

Returns:
all counters.


Copyright © 2013 Apache Software Foundation. All Rights Reserved.