From: <bsc...@us...> - 2010-09-30 12:38:48
|
Revision: 7737 http://unicore.svn.sourceforge.net/unicore/?rev=7737&view=rev Author: bschuller Date: 2010-09-30 12:38:42 +0000 (Thu, 30 Sep 2010) Log Message: ----------- remove outdated docs Removed Paths: ------------- metrix/trunk/doc/programming_model.png metrix/trunk/doc/readme.htm Deleted: metrix/trunk/doc/programming_model.png =================================================================== (Binary files differ) Deleted: metrix/trunk/doc/readme.htm =================================================================== --- metrix/trunk/doc/readme.htm 2010-09-30 12:34:48 UTC (rev 7736) +++ metrix/trunk/doc/readme.htm 2010-09-30 12:38:42 UTC (rev 7737) @@ -1,295 +0,0 @@ -<html> -<head> -<title>[primer] metriX</title> - -<body> -<h1>Introduction</h1> -<br><br> -Being a code instrumentation metric framework, metriX enables you to solely focus on metric logic when writing custom metric classes. -<br> - -<table align="center"> -<tr><td align="center"><img src="programming_model.png"></td></tr> -<tr><td align="center">Fig. 1 – metriX programming model</td></tr> -</table> - -<br><br> -The programming model (see fig. 1) consists of 5 components: -<br><br> -<li> <i>instrumentingObject</i>: this is where you add instrumentation code to your application (the object the method(s) of which contains the instrumentation code) -<li> <i>myMetric</i>: an instance of a custom metric class -<li> <i>messageQueue</i>: the message queue belonging to <i>myMetric</i> -<li> <i>subscriber</i>: represents consumers of metric result values -<li> <i>MetricRegistry</i>: a central registry containing references to all registered metric instances and categories and providing different mechanisms to access all that data - - -<br><br> - -<table> - - <tr> - <td><b>1a</b></td> - <td><i>instrumentingObject</i> creates an instance <i>myMetric</i> of a custom metric class</td> - </tr> - <tr> - <td><b>1b</b></td> - <td><i>myMetric</i> registers itself with <i>MetricRegistry</i></td> - </tr> - <tr> - <td><b>2</b></td> - <td><i>instrumentingObject</i> pushes data pertinent to metric computation to <i>myMetric</i> (see 1.1)</td> - </tr> - <tr> - <td><b>3</b></td> - <td>Once <i>myMetric</i> has received all expected data (see 1.1), it will use them to compute a result.</td> - </tr> - <tr> - <td><b>4</b> + <b>5</b></td> - <td>Once this result has been computed, <i>myMetric</i> will publish it to its own <i>messageQueue</i> where it can be retrieved by interested <i>subscribers</i>.</td> - </tr> - <tr> - <td></td> - <td>Apart from that, <i>MetricRegistry</i> provides subscribers with different metric retrieval methods (see 1.3).</td> - </tr> - -</table> - - -<br><br> - - - - - - - - - -<h1>1. Basics</h1> - -<br><br> - -<h2>1.1 Write your own metric class.</h2> - - -<table> - <tr> - <td>In order to write your custom metric class, you simply need to<br> -<br> -1. subclass AbstractMetric<br> -2. provide a constructor where you specify the expected data along with the data type<br> -3. override 'public abstract Object AbstractMetric._compute()' to specifiy your metric computation logic<br></td> - </tr> - <tr> - <td><br></td> - </tr> - <tr> - <td bgcolor="silver">public class StopWatch extends AbstractMetric {<br> -<br> - public static final String TIME_START = "timeStart";<br> - public static final String TIME_END = "timeEnd";<br><br> - public StopWatch(Object component, String gaugeName, MetricInstanceConfig config) {<br> - super(component, gaugeName, config);<br> - expectedData.add(new ExpectedData(StopWatch.TIME_START, long.class));<br> - expectedData.add(new ExpectedData(StopWatch.TIME_END, long.class));<br> - }<br> -<br> - @Override<br> - public Long _compute() {<br> - long timeStart = (Long) data.get(StopWatch.TIME_START);<br> - long timeEnd = (Long) data.get(StopWatch.TIME_END);<br> - return timeEnd-timeStart;<br> - }<br> -}<br></td> - </tr> -</table> - - - -<h2>1.2 Instrument your code</h2> - -<table> - <tr> - <td><br>...<br></td> - </tr> - <tr> - <td bgcolor="silver"><br>StopWatch sw = new StopWatch(this, "someMeaningfulMarker", null);<br>sw.push(new MetricParameter(StopWatch.TIME_START, System.currentTimeMillis()));</td> - </tr> - <tr> - <td><br>...<br></td> - </tr> - <tr> - <td bgcolor="silver"><br>sw.push(new MetricParameter(StopWatch.TIME_END, System.currentTimeMillis()));</td> - </tr> - <tr> - <td><br>...<br></td> - </tr> -</table> - - -<h2>1.3 Retrieve metric results</h2> -<br><br> -Being usually decoupled from metric capturing locations, subscribers need a way to access metric instances -without having direct references to them in the first place.<br><br> - - -<table> - <tr> - <td>Once you have access to a metric instance, you can use it to access its message queue:</td> - </tr> - <tr> - <td bgcolor="silver">IMetric metric = MetricRegistry.getInstance().getMetric("c3175c43-ebae-4e55-bc9f-3f7645c493f4");<br> - metric.getMessageQueue().getCurrentResult(); // get the current result<br> - metric.getMessageQueue().getOldestResult(this); // get oldest result from a subscriber's point of view<br></td> - </tr> - <tr> - <td><br></td> - </tr> - <tr> - <td>In both cases, the return type is <b>Object</b>, so you need to cast it appropriately.</td> - </tr> -</table> - - -<br><br> - -Direct metric instance retrieval -<br><br> -<table> - <tr> - <td>– by id:</td> - </tr> - <tr> - <td bgcolor="silver">IMetric metric = MetricRegistry.getInstance().getMetric("c3175c43-ebae-4e55-bc9f-3f7645c493f4");</td> - </tr> - <tr> - <td><br></td> - </tr> - <tr> - <td></td> - </tr> - <tr> - <td>– by instrumenting component, metric class, gauge name:</td> - </tr> - <tr> - <td bgcolor="silver">StopWatch sw = MetricRegistry.getInstance().getMetric(this, StopWatch.class, "someMeaningfulMarker");</td> - </tr> - <tr> - <td><br></td> - </tr> - <tr> - <td></td> - </tr> - <tr> - <td>Additionally, you can get all metric instances having been created by a specific instrumenting object:</td> - </tr> - <tr> - <td bgcolor="silver">IMetric[] metrics = MetricRegistry.getInstance().getMetricsForComponent(instrumentingComponent);</td> - </tr> -</table> - -<br><br> - - -<br><br> - - -You can also use drill-down approaches to filter down specific metric instances from a whole bunch -<br><br> -<table> - <tr> - <td>– either by retrieving IDs of all registered metric instances in the system to iterate through all metric -instances using individual search criteria:</td> - </tr> - <tr> - <td bgcolor="silver">String[] allIDs = MetricRegistry.getInstance().getMetricIDs();<br><br> - <br>for(String id:allIDs) {<br> - IMetric metric = MetricRegistry.getInstance().getMetric(id);<br> - // do something meaningful<br> - } - </td> - </tr> - <tr> - <td> - </td> - </tr> - <tr> - <td><br></td> - </tr> - <tr> - <td></td> - </tr> - <tr> - <td>– or by using categories as filter values</td> - </tr> - <tr> - <td bgcolor="silver">IMetric[] metrics = MetricRegistry.getInstance().getMetricsForCategory("SomeCategory");</td> - </tr> - <tr> - <td><br></td> - </tr> - <tr> - <td></td> - </tr> - <tr> - <td>In the same vein, all registered categories can be listed using</td> - </tr> - <tr> - <td bgcolor="silver">String[] categories = MetricRegistry.getInstance().getMetricCategories();</td> - </tr> -</table> - - -<br><br> - -<table> - <tr> - <td>Optionally, you can add a <i>@MetricProperties</i> annotation to your custom metric class to provide useful metadata. This accommodates the readability of your metric instances in the JMX console (provided you're going to activate the JMX tie-in) and additional custom scenarios displaying metric-related information.:</td> - </tr> - <tr> - <td bgcolor="silver">@MetricProperties(name="StopWatch",<br> - unit="ms",<br> - humanReadableDescription="This is a stop watch computing the time difference of the 'timeEnd' and 'timeStart' parameters.",<br> - categories={@MetricCategory(category="Timer")})<br></td> - </tr> -</table> - -<br><br> -<br><br> - - -<h1>2. Advanced</h1> - -[This section isn't finished, yet.] - -<h2>2.1 How to configure a metric instance</h2> - -<br> - -<table> - <tr> - <td><br>...<br></td> - </tr> - <tr> - <td bgcolor="silver"><br>MetricInstanceConfig config = new MetricInstanceConfig();<br> -config.enablePersistence(true);<br> -config.setPackageSize(50);<br> -config.setMonitoringDuration(20);<br><br>StopWatch sw = new StopWatch(this, "someMeaningfulMarker", config);<br>sw.push(new MetricParameter(StopWatch.TIME_START, System.currentTimeMillis()));</td> - </tr> - <tr> - <td><br>...<br></td> - </tr> - <tr> - <td bgcolor="silver"><br>sw.push(new MetricParameter(StopWatch.TIME_END, System.currentTimeMillis()));</td> - </tr> - <tr> - <td><br>...<br></td> - </tr> -</table> - - - - -</body> - -</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |