static BlobFactory getBlobStoreBlobFactory(final BlobStore store) { return in -> { String blobId; if (!ENABLE_ASYNC_DS) { blobId = store.writeBlob(in, new BlobOptions().setUpload(SYNCHRONOUS)); } else { blobId = store.writeBlob(in); } return new BlobStoreBlob(store, blobId); }; } }
@Override public String writeBlob(InputStream stream) throws IOException { return writeBlob(stream, new BlobOptions()); }
if (blobOptions.getUpload() == SYNCHRONOUS || !cache.stage(identifier.toString(), tmpFile)) { backend.write(identifier, tmpFile);
@Override public String writeBlob(InputStream stream) throws IOException { return writeBlob(stream, new BlobOptions()); }
if (blobOptions.getUpload() == SYNCHRONOUS || !cache.stage(identifier.toString(), tmpFile)) { backend.write(identifier, tmpFile);
static BlobFactory getBlobStoreBlobFactory(final BlobStore store) { return in -> { String blobId; if (!ENABLE_ASYNC_DS) { blobId = store.writeBlob(in, new BlobOptions().setUpload(SYNCHRONOUS)); } else { blobId = store.writeBlob(in); } return new BlobStoreBlob(store, blobId); }; } }
@Override public DataRecord addRecord(InputStream inputStream) throws DataStoreException { return addRecord(inputStream, new BlobOptions()); }
if (blobOptions.getUpload() == SYNCHRONOUS || !cache.stage(identifier.toString(), tmpFile)) { backend.write(identifier, tmpFile);
@Override protected DataRecord doSynchronousAddRecord(DataStore ds, InputStream in) throws DataStoreException { return ((AzureDataStore)ds).addRecord(in, new BlobOptions().setUpload(BlobOptions.UploadType.SYNCHRONOUS)); }
@Override public DataRecord addRecord(InputStream inputStream) throws DataStoreException { return addRecord(inputStream, new BlobOptions()); }
@Override protected DataRecord doSynchronousAddRecord(DataStore ds, InputStream in) throws DataStoreException { return ((S3DataStore)ds).addRecord(in, new BlobOptions().setUpload(BlobOptions.UploadType.SYNCHRONOUS)); }
@Override public DataRecord addRecord(InputStream inputStream) throws DataStoreException { return addRecord(inputStream, new BlobOptions()); }
/** * Add, get forcing load in cache. * @throws Exception */ @Test public void syncAddGetLoadCache() throws Exception { LOG.info("Starting syncAddGetForceFromCache"); File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile()); String id = getIdForInputStream(f); FileInputStream fin = new FileInputStream(f); closer.register(fin); DataRecord rec = dataStore.addRecord(fin, new BlobOptions().setUpload(SYNCHRONOUS)); assertEquals(id, rec.getIdentifier().toString()); assertFile(rec.getStream(), f, folder); // Invalidate from the local cache dataStore.getCache().invalidate(id); // Trigger load from backend File cacheDownloaded = dataStore.getCache().get(id); assertTrue(Files.equal(f, cacheDownloaded)); assertEquals(1, Iterators.size(dataStore.getAllIdentifiers())); LOG.info("Finished syncAddGetLoadCache"); }
@Override public String writeBlob(InputStream stream) throws IOException { return writeBlob(stream, new BlobOptions()); }
/** * Add, get, delete with synchronous option. * @throws Exception */ @Test public void syncAddGetDelete() throws Exception { LOG.info("Starting syncAddGetDelete"); File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile()); String id = getIdForInputStream(f); FileInputStream fin = new FileInputStream(f); closer.register(fin); DataRecord rec = dataStore.addRecord(fin, new BlobOptions().setUpload(SYNCHRONOUS)); assertEquals(id, rec.getIdentifier().toString()); assertFile(rec.getStream(), f, folder); rec = dataStore.getRecordIfStored(new DataIdentifier(id)); assertEquals(id, rec.getIdentifier().toString()); assertFile(rec.getStream(), f, folder); assertEquals(1, Iterators.size(dataStore.getAllIdentifiers())); dataStore.deleteRecord(new DataIdentifier(id)); rec = dataStore.getRecordIfStored(new DataIdentifier(id)); assertNull(rec); LOG.info("Finished syncAddGetDelete"); }
@Override public DataRecord addRecord(InputStream stream) throws DataStoreException { try { return writeStream(stream, new BlobOptions()); } catch (IOException e) { throw new DataStoreException(e); } }
@Override public DataRecord addRecord(InputStream stream) throws DataStoreException { try { return writeStream(stream, new BlobOptions()); } catch (IOException e) { throw new DataStoreException(e); } }
@Override public DataRecord addRecord(InputStream stream) throws DataStoreException { try { return writeStream(stream, new BlobOptions()); } catch (IOException e) { throw new DataStoreException(e); } }
@Override public String writeBlob(InputStream in) throws IOException { return writeBlob(in, new BlobOptions()); }
@Test(expected = UnsupportedOperationException.class) public void writingBinariesWithBlobOptsIsNotSupported() throws IOException { given: { final BlobStore blobStore = new LoopbackBlobStore(); final BlobOptions blobOptions = new BlobOptions(); when: { blobStore.writeBlob(adaptToUtf8InputStream("Test"), blobOptions); } } }