Skip to content
eawagner edited this page Jul 12, 2013 · 1 revision

Blob Store

At isn't core, the blob store is an API to allow for the storage of streams of data to the cloud with the additional added benefit of Accumulo's security mechanism.

How to use it

Using the BlobStore is very easy. Simply create a new instance of AccumuloBlobStore and provide it a Connector. From there you can get an OutputStream for storing data or an InputStream for retrieving data. The example class below shows how you would save save and retrieve a file using the BlobStore.

public class Example {

    private final BlobStore blobStore;

    public Example(Connector connector) throws Exception {
        blobStore = new AccumuloBlobStore(connector);
    }

    public void saveFile(String fileName, String blobKey, String blobType, String visibility)
            throws IOException {
        InputStream fileStream = null;
        OutputStream storageStream = null;

        try {
            fileStream = new FileInputStream(fileName);
            storageStream = blobStore.store(blobKey, blobType, System.currentTimeMillis(), visibility);
            IOUtils.copy(fileStream, storageStream); //Copy the input stream to the storage stream.
        } finally {
            //Don't forget to close your streams.
            Closeables.closeQuietly(fileStream);
            Closeables.closeQuietly(storageStream);
        }
    }
    
    public InputStream getBlob(String blobKey, String blobType, Auths authorizations) {
        return blobStore.get(blobKey, blobType, authorizations);
    }
}

Extensions to the Blob Store

There are two extension implementations that provide additional capabilities to basic functionality of the blobstore. Both of these implement the ExtendedBlobStore interface which provides additional functionality such storing additional properties about the data in the store. For example, to retrieve the size of the data in the store, you can simply replace the previous example with an ExtendedBlobStore and write a method such as the following.

public int getDataSize(String blobKey, String blobType, Auths authorizations) {
    return blobStore.blobSize(blobKey, blobType, authorizations);
}

The ExtendedAccumuloBlobStore provides the basic functionality for storing this additional information. The HighSpeedIngestBlobStore on the other hand provides the same functionality but without the checks to verify if data is already in the store and using a single writer to the database for all the storage streams.

The implementations for the ExtendedBlobStores are interchangeable so that ingest nodes can use the HighSpeedIngestBlobStore and write to the same store as the application that is using the ExtendedAccumuloBlobStore.

Clone this wiki locally