org.outerj.daisy.blobstore
Interface BlobStore

All Known Implementing Classes:
FSBlobStore

public interface BlobStore

Stores arbitrairy blob ("binary large object") data.

The store is a write-once, read-many type of store. An existing blob cannot be updated, rather a new one needs to be written.

The user of the BlobStore is himself responsible not to retrieve or delete a blob before it is completely written.


Method Summary
 void delete(java.lang.String name)
           
 EDU.oswego.cs.dl.util.concurrent.Sync getAvoidSuspendLock()
          Returns a lock which can be acquired to avoid that the BlobStore can go into suspension while you have this lock.
 void resumeWrites()
          Resumes write operations (after being suspended with suspendWrites(long).
 java.io.InputStream retrieve(java.lang.String name)
          The caller is responsible himself that a file is not being read before it is completely written.
 java.lang.String store(byte[] data)
          Returns an auto-generated key by which the blob can later be retrieved.
 java.lang.String store(java.io.InputStream is)
          Returns an auto-generated key by which the blob can later be retrieved.
 boolean suspendWrites(long msecs)
          Suspends all write operations to the blob store, after calling this method only read operation will be allowed.
 

Method Detail

store

java.lang.String store(byte[] data)
                       throws BlobIOException
Returns an auto-generated key by which the blob can later be retrieved.

Throws:
BlobIOException

store

java.lang.String store(java.io.InputStream is)
                       throws BlobIOException
Returns an auto-generated key by which the blob can later be retrieved. The InputStream will be closed for you.

Throws:
BlobIOException

retrieve

java.io.InputStream retrieve(java.lang.String name)
                             throws BlobIOException,
                                    NonExistingBlobException
The caller is responsible himself that a file is not being read before it is completely written. The caller is also responsible for making sure the stream gets closed, otherwise resource might leak (thus: always in a try-catch block!).

Throws:
BlobIOException
NonExistingBlobException

delete

void delete(java.lang.String name)
            throws NonExistingBlobException
Throws:
NonExistingBlobException

suspendWrites

boolean suspendWrites(long msecs)
                      throws java.lang.InterruptedException
Suspends all write operations to the blob store, after calling this method only read operation will be allowed. This method only returns after all active write operations have been finished.

Parameters:
msecs - max time to wait for active write operations to finish
Throws:
java.lang.InterruptedException

resumeWrites

void resumeWrites()
Resumes write operations (after being suspended with suspendWrites(long).


getAvoidSuspendLock

EDU.oswego.cs.dl.util.concurrent.Sync getAvoidSuspendLock()
Returns a lock which can be acquired to avoid that the BlobStore can go into suspension while you have this lock.



Copyright © -2012 . All Rights Reserved.