SMILA/Documentation/Record Storage

From Eclipsepedia

< SMILA‎ | Documentation
Revision as of 05:01, 24 January 2012 by Juergen.schumacher.attensity.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Overview

Record Storage Service provides an easy way to store / access record objects. It does not persist any attachments included in the records, only the Id and the metadata. To persist attachments one has to use the Binary Storage.

Note.png
Unused since SMILA 0.9 Currently there is no SMILA component that actually writes records to record storage, because record metadata is now stored in "bulks" for processing (see SMILA/Documentation/JobManager). However, if you need it, you could easily write a pipelet that stores each processed record in record storage, too, and add it to your workflows. If you happen to write such a pipelet, it would be very kind to submit it as a contribution. Thank you :-)


API

  /**
   * Load the record with the given Id.
   * @param id Id of the record
   * @return a Record object or null, if no record with the given Id exists
   * @throws RecordStorageException if any error occurs
   */
  Record loadRecord(Id id) throws RecordStorageException;
 
  /**
   * Stores the given Record object. An existing Record with the same ID is overwritten by the given record.
   * @param record the Record object
   * @throws RecordStorageException if any error occurs
   */
  void storeRecord(Record record) throws RecordStorageException;
 
  /**
   * Removes the record with the given Id.
   * @param id Id of the record
   * @throws RecordStorageException if any error occurs
   */
  void removeRecord(Id id) throws RecordStorageException;
 
  /**
   * Checks if a Record with the given Id exists in the storeage.
   * @param id Id of the record
   * @return true if a record with the given Id exists, false otherwise
   * @throws RecordStorageException if any error occurs
   */
  boolean existsRecord(Id id) throws RecordStorageException;
 
  /**
   * Loads all records of the given source.
   * @param source the name of the data source
   * @return an Iterator over the Record objects
   * @throws RecordStorageException if any error occurs
   */
  Iterator<Record> loadRecords(String source) throws RecordStorageException;

Implementations

It is possible to provide different implementations for the RecordStorage interface. Below is a list of the currently available implementations.

org.eclipse.smila.recordstorage.impl

The default implementation uses eclipseLink JPA to store the records in an apache derby database. The data is stored in the table RECORDS:

RECORDS
Column Type Description
ID VARCHAR a hashed value of the Id object of the record
SOURCE VARCHAR the source attribute of the Id object
RECORD BLOB the serialized record object without attachments


Configuration

Note.png
todo
this section needs to take this new page into account: SMILA/Documentation/General_JPA_Configuration_in_SMILA


The only configuration needed is a typicall eclipseLink configuration property file. Therin you can specify settings for logging, database connection settings. For more information please refer to the eclipseLink documentation [[1]]. The configuration is located at configuration/org.eclipse.smila.recordstorage.impl/org.eclipse.smila.recordstorage.impl/persistence.properties.

# EclipseLink properties
eclipselink.logging.level=INFO
eclipselink.target-server=None
eclipselink.target-database=org.eclipse.persistence.platform.database.DerbyPlatform
eclipselink.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
eclipselink.jdbc.url=jdbc:derby:workspace/.metadata/.plugins/org.eclipse.smila.recordstorage.impl/recordstorage;create=true
eclipselink.jdbc.password=smila
eclipselink.jdbc.user=smila
eclipselink.ddl-generation=create-tables

After starting Smila for the first time, the DDL generation setting will print out some nasty warnings, complaining that it can't create some tables. These warnings are not critical. You can get rid of them by setting eclipselink.ddl-generation=none, but only after Smila was started at least once (and the tables were created).

Limitations

At the moment it is necessary to import all packages containing JDBCDriver classes in bundle org.eclipse.smila.recordstorage.impl. So for changing from derby to another database it is not sufficient to change the configuration in persistence.properties, you also have to add import package statementsv for the JDBC driver to use to your bundles manifest. This will hopefully be changed with the next release of eclipseLink.