org.apache.oozie.util
Class MetricsInstrumentation

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

public class MetricsInstrumentation
extends Instrumentation

Instrumentation framework that is mostly compatible with Instrumentation but is backed by Codahale Metrics. This class was designed to minimize the changes required to switch from Instrumentation to MetricsInstrumentation by keeping the same API. However, certain operations are obviously implemented differently or are no longer needed; and the output format is a little different. Internally, this class maps Cron to Timer, Variable to Gauge, counter to Counter, and Sampler to Histogram.


Nested Class Summary
static class MetricsInstrumentation.Sampler
           
 
Nested classes/interfaces inherited from class org.apache.oozie.util.Instrumentation
Instrumentation.Cron, Instrumentation.Element<T>, Instrumentation.Timer, Instrumentation.Variable<T>
 
Constructor Summary
MetricsInstrumentation()
          Creates the MetricsInstrumentation and starts taking some metrics.
 
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()
          Not Supported: throws UnsupportedOperationException
 Map<String,Map<String,Instrumentation.Element<Long>>> getCounters()
          Not Supported: throws UnsupportedOperationException
 Map<String,Map<String,Instrumentation.Element<Double>>> getSamplers()
          Not Supported: throws UnsupportedOperationException
 Map<String,Map<String,Instrumentation.Element<Instrumentation.Timer>>> getTimers()
          Not Supported: throws UnsupportedOperationException
 Map<String,Map<String,Instrumentation.Element<Instrumentation.Variable>>> getVariables()
          Not Supported: throws UnsupportedOperationException
 void incr(String group, String name, long count)
          Increment an instrumentation counter.
 void setScheduler(ScheduledExecutorService scheduler)
          Set the scheduler instance to handle the samplers.
 String toString()
          Return the string representation of the instrumentation.
 void writeJSONResponse(OutputStream os)
          Converts the current state of the metrics and writes them to the OutputStream.
 
Methods inherited from class org.apache.oozie.util.Instrumentation
getConfiguration, getJavaSystemProperties, getOSEnv
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetricsInstrumentation

public MetricsInstrumentation()
Creates the MetricsInstrumentation and starts taking some metrics.

Method Detail

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.

Internally, this is backed by a Timer.

Overrides:
addCron in class Instrumentation
Parameters:
group - timer group.
name - timer name.
cron - cron to add to the timer.

addVariable

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

Internally, this is backed by a Gauge.

Overrides:
addVariable in class Instrumentation
Parameters:
group - counter group.
name - counter name.
variable - variable to add.

incr

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

Internally, this is backed by a Counter.

Overrides:
incr in class Instrumentation
Parameters:
group - counter group.
name - counter name.
count - increment to add to the counter.

addSampler

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

Internally, this is backed by a biased (decaying) Histogram.

Overrides:
addSampler in class Instrumentation
Parameters:
group - timer group.
name - timer name.
period - (ignored)
interval - sampling frequency, how often the variable is probed.
variable - variable to sample.

setScheduler

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

Overrides:
setScheduler in class Instrumentation
Parameters:
scheduler - scheduler instance.

toString

public String toString()
Return the string representation of the instrumentation. It does a JSON pretty-print.

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

writeJSONResponse

public void writeJSONResponse(OutputStream os)
                       throws IOException
Converts the current state of the metrics and writes them to the OutputStream.

Parameters:
os - The OutputStream to write the metrics to
Throws:
IOException

getAll

public Map<String,Map<String,Map<String,Object>>> getAll()
Not Supported: throws UnsupportedOperationException

Overrides:
getAll in class Instrumentation
Returns:
nothing

getCounters

public Map<String,Map<String,Instrumentation.Element<Long>>> getCounters()
Not Supported: throws UnsupportedOperationException

Overrides:
getCounters in class Instrumentation
Returns:
nothing

getSamplers

public Map<String,Map<String,Instrumentation.Element<Double>>> getSamplers()
Not Supported: throws UnsupportedOperationException

Overrides:
getSamplers in class Instrumentation
Returns:
nothing

getTimers

public Map<String,Map<String,Instrumentation.Element<Instrumentation.Timer>>> getTimers()
Not Supported: throws UnsupportedOperationException

Overrides:
getTimers in class Instrumentation
Returns:
nothing

getVariables

public Map<String,Map<String,Instrumentation.Element<Instrumentation.Variable>>> getVariables()
Not Supported: throws UnsupportedOperationException

Overrides:
getVariables in class Instrumentation
Returns:
nothing


Copyright © 2015 Apache Software Foundation. All Rights Reserved.