Jump to: navigation, search

Difference between revisions of "SMILA/Documentation/Binary Storage"

m (Configuration)
m (Configuration)
Line 13: Line 13:
 
* org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOHierarchicalManager
 
* org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOHierarchicalManager
 
* org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOFlatManager
 
* org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOFlatManager
 +
 +
Configuration example:
 +
 +
<source lang="xml">
 +
<BinaryStorageConfiguration xmlns="http://www.eclipse.org/smila/binarystorage"
 +
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
  xsi:noNamespaceSchemaLocation="schemas/BinaryStorageConfiguration.xsd"
 +
  name="default1"
 +
  provider="file"
 +
  mountPoint="default"
 +
  implementationClass="org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOHierarchicalManager"
 +
  tempFileName="dummy.dat"
 +
/>
 +
</source>
  
 
In the next future there will be other available managers that provides the appropriate implementation for Binary Storage persistence structure.
 
In the next future there will be other available managers that provides the appropriate implementation for Binary Storage persistence structure.

Revision as of 01:05, 11 March 2009

Overview

Binary Storage Service provides an easy way to store / access binary data documents.

Client components access the Binary Storage Service for persisting binary data (attachments) into the binary storage. The binary data are identified by a unique key / identifier as a String data type.

Configuration

Currently, Binary Storage is able to run and store data into a hierarchical structure (uses deterministically calculation based on the hash id passed by the client component, like the ID passed from the Blackboard Service) and flat structure.

To configure the needed persistence storage structure, simply edit the /configuration/org.eclipse.smila.binarystorage/BinaryStorageConfiguration.xml file and change the value of implementationClass attribute to the one of the following available possibilities:

  • org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOHierarchicalManager
  • org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOFlatManager

Configuration example:

<BinaryStorageConfiguration xmlns="http://www.eclipse.org/smila/binarystorage" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:noNamespaceSchemaLocation="schemas/BinaryStorageConfiguration.xsd" 
  name="default1" 
  provider="file" 
  mountPoint="default"	
  implementationClass="org.eclipse.smila.binarystorage.internal.impl.persistence.filesystem.IOHierarchicalManager" 
  tempFileName="dummy.dat" 
/>

In the next future there will be other available managers that provides the appropriate implementation for Binary Storage persistence structure.

The Binary Storage Configuration will be changed soon.

API

void store(String id, InputStream stream);
void store(String id, byte[] blob)
byte[] fetchAsByte(String id)
InputStream fetchAsStream(String id)
void remove(String id)
int fetchSize(String id)

API Usage

BinaryStorageService binaryStorageService = ...; // Obtain the binary storage service
String attacmentIdKey = ...; // Unique ID
byte[] dataRecord = ... // Build record
 
// Store the binary record as byte array
binaryStorageService.store(attacmentIdKey, dataRecord);
 
// Fetch record as stream
final InputStream stream = binaryStorageService.fetchAsStream(attacmentIdKey);
 
// Define new ID and store new data from the first record's input stream
final String newAttacmentIdKey = attacmentIdKey + "0000";
binaryStorageService.store(newAttacmentIdKey, stream);
stream.close();
 
// Fetch the newest record as array of byte 
final byte[] recordByte = binaryStorageService.fetchAsByte(newAttacmentIdKey);
 
// The two records must have the same size
final int sizeInitial = _binaryStorageService.fetchSize(attacmentIdKey);
final int sizeFinal = binaryStorageService.fetchSize(newAttacmentIdKey);
 
// Remove the two records
binaryStorageService.remove(attacmentIdKey);
binaryStorageService.remove(newAttacmentIdKey);