Overview
The RM Statistics Service allows different backend applications to provide statistical information about their runtime behavior, and other applications to retrieve this information. The common principles of the Statistics Service are described in the Statistics Service document from Conceptual Guide.
The Statistics API allows system developers to:
- Create custom backend bundles that provide miscellaneous statistical information.
- Obtain statistical information from the statistics system through bundles running on the backend or non-RM applications running remotely on external systems/applications.
Statistic Provider Examples
PUSH Provider
How to create PUSH provider:
// create providerfinal BasicStatisticProvider provider = new BasicStatisticProvider( "OS", "Used Memory", // group and name of statistic newString[] {ReportProvider.AVERAGE, ReportProvider.MAX, ReportProvider.MIN}, // supported reports MergeProvider.SUM, // how current values on more than one hosts will be merged false, // if has current value support, may be true or false DatabaseProvider.RDBMS // database provider ); // register it bc.registerService(StatisticProvider.class.getName(), periodicProvider, null); // now someone shall put snapshots when value changes for (int i = 0; i < 1000; i++) { provider.putSnapshot(new Snapshot(i)); Thread.sleep(1000); }POLL Provider
How to create POLL provider:
// create providerfinal StatisticProvider periodicProvider = new BasicPeriodicStatisticProvider( "OS", "Used Memory", // group and name of statistic newString[] {ReportProvider.AVERAGE, ReportProvider.MAX, ReportProvider.MIN}, // supported reports MergeProvider.SUM, // how current values on more than one hosts will be merged true, // if has current value support, if false the provider shall override getSnapshot method DatabaseProvider.RDBMS, // database provider 10000 // period in milliseconds on which the provider will be polled for current value using method tick() ){ publicNumber getCurrentValue(final Source source) { return 0; // retrieve and return real value } }; // register it bc.registerService(StatisticProvider.class.getName(), periodicProvider, null); // provider will be polled at 10sec for its current value and it will be appended to the statistics