Difference between revisions of "Accounting Library"

From Gcube Wiki
Jump to: navigation, search
(Usage Record Record Validation and Harmonization)
Line 35: Line 35:
 
This functionality is very useful especially when the developer use a the key-value method.
 
This functionality is very useful especially when the developer use a the key-value method.
  
==== Internal Representation ====
+
for further details see [[Accounting Model]].
 
+
 
+
==== Internal Facilities ====
+
  
 
=== Buffering & Aggregating Usage Record ===
 
=== Buffering & Aggregating Usage Record ===
  
The library provide bufferization capabilities.
+
The library provide buffering capabilities.
While the records are buffered for each new records requested to be accounted the library try to aggregate the new record with the one has already buffered. The aggregation made in this phase is lossless.
+
While the records are buffered for each new records requested to be accounted the library try to aggregate the new record with the one has already buffered. The aggregation made in this phase is lossless. In other words, the ''UsageRecord'' aggregated are only the ones having the same values for required fields.
  
 
=== Storing Usage Record ===
 
=== Storing Usage Record ===
  
* Fallback
+
The library discover dynamically the '''Accounting Persistence Lib''' to persist the ''UsageRecord''s.
 +
If no library is discovered or if the storing fails (e.g. for network issue) the ''UsageRecord''s are persisted using a '''Fallback Persistence''' (on filesystem).
 +
There is a recurrent task which periodically (10 min and only if an '''Accounting Persistence Lib''' has been discovered on classpath) retry to persist ''UsageRecord''s persisted from '''FallBack Persistence''' (on filesystem).
  
 
== Development ==
 
== Development ==

Revision as of 10:59, 1 December 2015

This component is responsible of collecting, harmonizing and storing accounting data.

Accounting Lib in the Accounting Architecture

The following image show the components discussed in this wiki page in the full Accounting Architecture:

Accounting-architecture-accounting-lib.png

Library

The library has been tough to provide a common way to elaborate Usage Record (UR) (see Accounting Model to check which Usage Records are supported by default). In particular is responsible for:

  • Collecting
  • Aggregating
  • Buffering
  • Storing

Collecting Usage Record

The library allow to collect Usage Records providing the following functionality:

  • Attribute Validation and Harmonization
  • Usage Record Validation

To set the various properties of an usage records two different methods are available

  • Developer Friendly methods (getter and setter)
  • Generic Key-Value method (key:String, value:Comparable<? extends Serializable> )

For the same attribute each of the record is idempotent. This means that any of the way you are using to set a properties the value is always validated and harmonized by the same code. Different methods for different properties can be used together.

Moreover you can provide a Map<String,Comparable<? extends Serializable>> to set all properties at once.

Usage Record Record Validation and Harmonization

This library provide support to validate and harmonize the values to a common type (e.g. the string representation on an integer to a integer type, the string representation of an enum to the enum type). This functionality is very useful especially when the developer use a the key-value method.

for further details see Accounting Model.

Buffering & Aggregating Usage Record

The library provide buffering capabilities. While the records are buffered for each new records requested to be accounted the library try to aggregate the new record with the one has already buffered. The aggregation made in this phase is lossless. In other words, the UsageRecord aggregated are only the ones having the same values for required fields.

Storing Usage Record

The library discover dynamically the Accounting Persistence Lib to persist the UsageRecords. If no library is discovered or if the storing fails (e.g. for network issue) the UsageRecords are persisted using a Fallback Persistence (on filesystem). There is a recurrent task which periodically (10 min and only if an Accounting Persistence Lib has been discovered on classpath) retry to persist UsageRecords persisted from FallBack Persistence (on filesystem).

Development

The library is identified by the following maven coordinates:

<groupId>org.gcube.accounting</groupId>

<artifactId>accounting-lib</artifactId>


Persistence

The current implementation of persistence for this library is for CouchDB storage.

<groupId>org.gcube.accounting</groupId>

<artifactId>accounting-lib-persistence-couchdb</artifactId>


Less dependency is better than more

This library must be available on every node of the infrastructure. To respect as much possible ZERO-DEPENDENCY paradigm of SmartGears a simple couchdb-connector (simple HTTP client library) has been developed.


Deployment