Common-accounting ABANDONED

From Gcube Wiki
Revision as of 11:23, 10 December 2013 by Ermanno.travaglino (Talk | contribs) (Scope)

Jump to: navigation, search

Scope

This library abstracts the underlying messaging infrastructure in order to provide some facilities both for the services and for the accounting system (i.e. Usage Tracker). The common-accounting-lib allows the services to send the accounting records on the broker and allows the accounting system to receive these messages. In our enviroment, the broker is represented by ActiveMQ, which is already replicated with some failover endpoints, in order to increase fault tolerance and scalability. Each infrastructure instance (such as dev, testing and production) has a running instance, that is related to the scope of the infrastructure. This behavior needs to be mirrored even on the accounting library.

Find common-accounting-lib on Nexus Repository Browser for an artifact with the following coordinates:

<dependency>
	<groupId>org.gcube.accounting</groupId>
	<artifactId>common-accounting-lib</artifactId>
</dependency>

Design and implementation notes

The "common-accounting" library contains:

  • the resource accounting data-model (common-accounting-model);
  • a producer to publish raw accounting data on the messaging broker
  • a consumer to retrieve raw accounting data

At the producer-side, the library uses the Messaging Endpoints library to harvest the Message Broker instances addresses that are published on the IS. At the consumer-side, the library makes no assumptions on the underlying infrastructure. The service that acts as a consumer needs to provide broker endpoint(s) and scope(s) where the accounting information are available and ready to be consumed. This behaviour stems from the fact that the consumer is the Usage Tracker which is agnostic from the gCube infrastructure.

Usage

In order to use the common-accounting-lib to publish accounting records some steps are required:

  • add the Maven dependency of the library in your pom
  • decide where is more appropriate to implement the accounting logic.
  • instantiate a new RawUsageRecord object, which represents the Java implementation of the Resource Accounting model.
  • fill all the basic fields of the record and, optionally, fill even the resource specific fields.
  • get the ResourceAccounting instance through the available factory.
  • and, finally, send a message to the accounting system with the sendAccountingMessage method, passing as a parameter the RawUsageRecord object.