org.fcrepo.server.storage.lowlevel.akubra
Class AkubraLowlevelStorage

java.lang.Object
  extended by org.fcrepo.server.storage.lowlevel.akubra.AkubraLowlevelStorage
All Implemented Interfaces:
IListable, ILowlevelStorage, ISizable

public class AkubraLowlevelStorage
extends Object
implements ILowlevelStorage, IListable, ISizable

Akubra-backed implementation of ILowlevelStorage.

This implementation uses two Akubra BlobStores; one for objects and another for datastreams.

Author:
Chris Wilper

Constructor Summary
AkubraLowlevelStorage(org.akubraproject.BlobStore objectStore, org.akubraproject.BlobStore datastreamStore, boolean forceSafeObjectOverwrites, boolean forceSafeDatastreamOverwrites)
          Creates an instance using the given blob stores.
 
Method Summary
 long addDatastream(String dsKey, InputStream content)
          Sets the content of a new datastream version.
 void addObject(String objectKey, InputStream content)
          Adds a new object.
 void auditDatastream()
          Performs a consistency check against the datastream index if such an index exists.
 void auditObject()
          Performs a consistency check against the object index if such an index exists.
 long getDatastreamSize(String dsKey)
          Return the size of a datastream in bytes
 Iterator<String> listDatastreams()
          Lists all stored datastreams in no particular order.
 Iterator<String> listObjects()
          Lists all stored objects in no particular order.
 void rebuildDatastream()
          Reconstructs the datastream index if such an index exists.
 void rebuildObject()
          Reconstructs the object index if such an index exists.
 void removeDatastream(String dsKey)
          Removes the content of an existing datastream version.
 void removeObject(String objectKey)
          Removes an object.
 long replaceDatastream(String dsKey, InputStream content)
          Sets the content of an existing datastream version.
 void replaceObject(String objectKey, InputStream content)
          Replaces an existing object.
 InputStream retrieveDatastream(String dsKey)
          Gets the content of an existing datastream version.
 InputStream retrieveObject(String objectKey)
          Gets an existing object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AkubraLowlevelStorage

public AkubraLowlevelStorage(org.akubraproject.BlobStore objectStore,
                             org.akubraproject.BlobStore datastreamStore,
                             boolean forceSafeObjectOverwrites,
                             boolean forceSafeDatastreamOverwrites)
Creates an instance using the given blob stores.

The blob stores MUST:

The blob stores MAY:

Parameters:
objectStore - the store for serialized objects.
datastreamStore - the store for datastream content.
forceSafeObjectOverwrites - if true, replaceObject calls will be done in a way that ensures the old content is not deleted until the new content is safely written. If the objectStore already does this, this should be given as false.
forceSafeDatastreamOverwrites - same as above, but for replaceDatastream calls.
Method Detail

addDatastream

public long addDatastream(String dsKey,
                          InputStream content)
                   throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Sets the content of a new datastream version.

Specified by:
addDatastream in interface ILowlevelStorage
Parameters:
dsKey - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
content - the content.
Throws:
LowlevelStorageException - if the datastream version already exists or cannot be added for any other reason.

addObject

public void addObject(String objectKey,
                      InputStream content)
               throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Adds a new object.

Specified by:
addObject in interface ILowlevelStorage
Parameters:
objectKey - the pid of the object.
content - the serialized object.
Throws:
LowlevelStorageException - if the object already exists or cannot be added for any other reason.

auditDatastream

public void auditDatastream()
                     throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Performs a consistency check against the datastream index if such an index exists. The datastream index associates a datastream version with a stored location. If the implementation does not use an index, this is a no-op. If any inconsistencies are found, they will be reported to the system logger.

Specified by:
auditDatastream in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the consistency check from taking place.

auditObject

public void auditObject()
                 throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Performs a consistency check against the object index if such an index exists. The object index associates an object with a stored location. If the implementation does not use an index, this is a no-op. If any inconsistencies are found, they will be reported to the system logger.

Specified by:
auditObject in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the consistency check from taking place.

rebuildDatastream

public void rebuildDatastream()
                       throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Reconstructs the datastream index if such an index exists. The datastream index associates a datastream version with a stored location. If the implementation does not use an index, this is a no-op.

Warning

Rebuilding the datastream index is not expected to be an atomic operation and should only be run while the system is offline or reads and writes are otherwise prevented.

Specified by:
rebuildDatastream in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the

rebuildObject

public void rebuildObject()
                   throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Reconstructs the object index if such an index exists. The object index associates an object with a stored location. If the implementation does not use an index, this is a no-op.

Warning

Rebuilding the object index is not expected to be an atomic operation and should only be run while the system is offline or reads and writes are otherwise prevented.

Specified by:
rebuildObject in interface ILowlevelStorage
Throws:
LowlevelStorageException - if an error occurs that prevents the index from being rebuilt.

removeDatastream

public void removeDatastream(String dsKey)
                      throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Removes the content of an existing datastream version.

Specified by:
removeDatastream in interface ILowlevelStorage
Parameters:
dsKey - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
Throws:
LowlevelStorageException - if the datastream version does not exist or cannot be removed for any other reason.

removeObject

public void removeObject(String objectKey)
                  throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Removes an object.

Specified by:
removeObject in interface ILowlevelStorage
Parameters:
objectKey - the pid of the object.
Throws:
LowlevelStorageException - if the object does not exist or cannot be removed for any other reason.

replaceDatastream

public long replaceDatastream(String dsKey,
                              InputStream content)
                       throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Sets the content of an existing datastream version.

Specified by:
replaceDatastream in interface ILowlevelStorage
Parameters:
dsKey - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
content - the content.
Throws:
LowlevelStorageException - if the datastream version does not already exist or cannot be replaced for any other reason.

replaceObject

public void replaceObject(String objectKey,
                          InputStream content)
                   throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Replaces an existing object.

Specified by:
replaceObject in interface ILowlevelStorage
Parameters:
objectKey - the pid of the object.
content - the serialized object.
Throws:
LowlevelStorageException - if the object does not already exist or cannot be replaced for any other reason.

retrieveDatastream

public InputStream retrieveDatastream(String dsKey)
                               throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Gets the content of an existing datastream version.

Specified by:
retrieveDatastream in interface ILowlevelStorage
Parameters:
dsKey - the $pid "+" $dsId "+" $dsVersionId string that uniquely identifies the datastream version.
Returns:
the content.
Throws:
LowlevelStorageException - if the datastream version does not exist or cannot be read for any other reason.

retrieveObject

public InputStream retrieveObject(String objectKey)
                           throws LowlevelStorageException
Description copied from interface: ILowlevelStorage
Gets an existing object.

Specified by:
retrieveObject in interface ILowlevelStorage
Parameters:
objectKey - the pid of the object.
Returns:
the serialized form of the object, as stored.
Throws:
LowlevelStorageException - if the object does not exist or cannot be read for any other reason.

listDatastreams

public Iterator<String> listDatastreams()
Description copied from interface: IListable
Lists all stored datastreams in no particular order.

Specified by:
listDatastreams in interface IListable
Returns:
an iterator of all stored datastream keys, each in the following format: $pid "+" $dsId "+" $dsVersionId

listObjects

public Iterator<String> listObjects()
Description copied from interface: IListable
Lists all stored objects in no particular order.

Specified by:
listObjects in interface IListable
Returns:
an iterator of all stored object pids.

getDatastreamSize

public long getDatastreamSize(String dsKey)
                       throws LowlevelStorageException
Description copied from interface: ISizable
Return the size of a datastream in bytes

Specified by:
getDatastreamSize in interface ISizable
Returns:
Throws:
LowlevelStorageException


Copyright © 2011 DuraSpace. All Rights Reserved.