Difference between revisions of "Accounting Aggregator"

From Gcube Wiki
Jump to: navigation, search
(How to manage calledMethod lead to ServiceUsageRecord can not be aggregated)
(How to manage calledMethod lead to ServiceUsageRecord cannot be aggregated)
Line 25: Line 25:
 
== How to manage calledMethod lead to ServiceUsageRecord cannot be aggregated  ==
 
== How to manage calledMethod lead to ServiceUsageRecord cannot be aggregated  ==
  
RESTFull (and RESt-like) services contain the ID of the managed resource inside the path of the URL. Smartgears auto calculate '''calledMethod''' by using the relative path of the URL.
+
RESTFull (and REST-like) services contain the ID of the managed resource inside the path of the URL. Smartgears auto calculate '''calledMethod''' by using the relative path of the URL.
 
This lead to have ServiceUsageRecord cannot be aggregated.
 
This lead to have ServiceUsageRecord cannot be aggregated.
 +
 +
To solve such an issue some actions are need from developers:
 +
 +
* Rewrite '''calledMethod''' in the service code
 +
* Provide regular expression to match old accounted records to allow to rewrite them from accoutnign-aggrator
 +
 +
=== Rewrite calledMethod ==='''calledMethod'''
 +
 +
The developer have to insert as first line of the entry method the following line of code to instruct Smartgears to set the desired '''calledMethod'''
 +
 +
<syntaxhighlight lang="java">
 +
CalledMethodProvider.instance.set("rewrittenCalledMethod");
 +
</syntaxhighlight>
 +
 +
Resource Registry is an example of how to properly use such a feature for RESTFull services.
 +
 +
For example Resource Registry use the following URLs to read/update/delete a Facet having UUID 4023d5b2-8601-47a5-83ef-49ffcbfc7d86
 +
 +
<pre>
 +
GET /resource-registry/er/facet/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
 +
</pre>
 +
 +
<pre>
 +
PUT /resource-registry/er/facet/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
 +
</pre>
 +
 +
<pre>
 +
DELETE /resource-registry/er/facet/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
 +
</pre>
 +
 +
If the service does not rewrite the '''calledMethod''' we have two effect:
 +
 +
* the three operation cannot be distinguished from accounting and lead to aggregate the records operating to the same facet.
 +
* the uuid does not allow to aggregate the operation across facets.
 +
 +
 +
Resource Registry instruct smartgears to rewrite the '''calledMethod''' as following:
 +
 +
<syntaxhighlight lang="java">
 +
CalledMethodProvider.instance.set("GET /resource-registry/er/facet/ID");
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="java">
 +
CalledMethodProvider.instance.set("PUT /resource-registry/er/facet/ID");
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="java">
 +
CalledMethodProvider.instance.set("DELETE /resource-registry/er/facet/ID");
 +
</syntaxhighlight>
 +
 +
 +
I  such a way the different methods are distinguishable and the ServiceUsageRecords can be aggregated across facets.
 +
 +
=== Provide regular expression ===

Revision as of 12:42, 2 January 2018

This component is responsible of aggregating the collected Accounting data.

Accounting Aggregator in the Accounting Architecture

The following image evidences the accounting-aggregator components as part of Accounting Architecture:

Accounting-architecture-accounting-aggregator.png

Accounting Aggregator Execution

This component is a Smart Executor plugin and is launched as Global Scheduled Task (see Smart Executor for further information)

It aggregates (lossless) accounted Usage Record. The scheduling plan is to run on different smart-executor equipped with this plugin with the following parameters:

  • Hourly => accounting records per hour are available for the past week;
  • Daily => accounting records per day are available for the past 3 months;
  • Monthly => accounting records per month are available for the past 3 years;
  • Yearly => accounting records per year are available for the past 10 years;


How to manage calledMethod lead to ServiceUsageRecord cannot be aggregated

RESTFull (and REST-like) services contain the ID of the managed resource inside the path of the URL. Smartgears auto calculate calledMethod by using the relative path of the URL. This lead to have ServiceUsageRecord cannot be aggregated.

To solve such an issue some actions are need from developers:

  • Rewrite calledMethod in the service code
  • Provide regular expression to match old accounted records to allow to rewrite them from accoutnign-aggrator

=== Rewrite calledMethod ===calledMethod

The developer have to insert as first line of the entry method the following line of code to instruct Smartgears to set the desired calledMethod

CalledMethodProvider.instance.set("rewrittenCalledMethod");

Resource Registry is an example of how to properly use such a feature for RESTFull services.

For example Resource Registry use the following URLs to read/update/delete a Facet having UUID 4023d5b2-8601-47a5-83ef-49ffcbfc7d86

GET /resource-registry/er/facet/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
PUT /resource-registry/er/facet/4023d5b2-8601-47a5-83ef-49ffcbfc7d86
DELETE /resource-registry/er/facet/4023d5b2-8601-47a5-83ef-49ffcbfc7d86

If the service does not rewrite the calledMethod we have two effect:

  • the three operation cannot be distinguished from accounting and lead to aggregate the records operating to the same facet.
  • the uuid does not allow to aggregate the operation across facets.


Resource Registry instruct smartgears to rewrite the calledMethod as following:

CalledMethodProvider.instance.set("GET /resource-registry/er/facet/ID");
CalledMethodProvider.instance.set("PUT /resource-registry/er/facet/ID");
CalledMethodProvider.instance.set("DELETE /resource-registry/er/facet/ID");


I such a way the different methods are distinguishable and the ServiceUsageRecords can be aggregated across facets.

Provide regular expression