Document Store Framework

From Gcube Wiki
Revision as of 14:45, 29 January 2016 by Luca.frosini (Talk | contribs) (Base Model)

Jump to: navigation, search

Document Store Lib Provides facilities to store document in a Document Store NoSQL DB. It provides Bufferization and Fallback capabilities.


Library

The library has been tough to provide a common way to store Records in Document Store NoSQL DB. In particular is responsible for:

  • Aggregating
  • Buffering
  • Storing

Base Model

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

  • Developer Friendly methods (getter and setter)
  • Generic Key-Value method
    • key:
      String
    • value:
      ? extends Serializable
  • Validating
  • Harmonizing

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,? extends Serializable>
to set all properties at once.


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 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 Record

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

Development

The library is identified by the following maven coordinates:

<groupId>org.gcube.data-publishing</groupId>

<artifactId>document-store-lib</artifactId>

Please set the scope of the library to PROVIDED, if your component runs on a container gHN or vHN.

Document Store Lib Persistence

The current implementations of persistence for this library are:

  • couchdb

<groupId>org.gcube.data-publishing</groupId>

<artifactId>document-store-lib</artifactId>


The developer MUST not depend from this library. This library is already available on container because has been included in gCore and smartgears bundles. Also, when a component does not run on a container , the component MUST not include this library as dependency. It will be responsibility of the person in charge of deploying the component to provide also that library.

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

Deployment

Docuemtn Lib and the Accounting Persistence Lib are already available on gCore and smartgears bundles (gHN and wHN).



Document Store Lib in the Accounting Architecture

The following image evidences the use of docuemtn-store-lib in Accounting Architecture:

Accounting-architecture-document-store-lib.png