@Override public String writeBlob(InputStream in) throws IOException { String blobId = newBlobStore.writeBlob(in); migratedBlobs.add(blobId); return blobId; }
@Override @NotNull public BlobStoreBlob createBlob(InputStream inputStream) throws IOException { return new BlobStoreBlob(blobStore, blobStore.writeBlob(inputStream)); }
@Override @NotNull public BlobStoreBlob createBlob(InputStream inputStream) throws IOException { return new BlobStoreBlob(blobStore, blobStore.writeBlob(inputStream)); }
private void writeBlob(String blobId, InputStream stream) { try { blobStore.writeBlob(stream); } catch (IOException e) { throw new BlobWriteException(blobId, e); } }
@Override public String writeBlob(InputStream in) throws IOException { String blobId = newBlobStore.writeBlob(in); migratedBlobs.add(blobId); return blobId; }
@Override public String writeBlob(InputStream in) throws IOException { String blobId = newBlobStore.writeBlob(in); migratedBlobs.add(blobId); return blobId; }
public String write(InputStream in) throws MicroKernelException { if (rep == null) { throw new IllegalStateException("this instance has already been disposed"); } try { return rep.getBlobStore().writeBlob(in); } catch (Exception e) { throw new MicroKernelException(e); } }
private void readBlob(String blobId, String pName) { Blob read = loader.readBlob(blobId); if (read != null) { try { store.getBlobStore().writeBlob(read.getNewStream()); } catch (IOException f) { throw new IllegalStateException("Unable to persist blob " + blobId + " at " + path + "#" + pName, f); } } else { throw new IllegalStateException("Unable to load remote blob " + blobId + " at " + path + "#" + pName); } }
private List<String> addBlobs(BlobStore blobStore) throws IOException { List<String> ids = new ArrayList<String>(); for (int i = 0; i < 5; i++) { byte[] buffer = new byte[LENGTH]; random.nextBytes(buffer); InputStream bis = new ByteArrayInputStream(buffer); ids.add(blobStore.writeBlob(bis)); } return ids; }
@Parameterized.Parameters(name="{1}") public static Collection<Object[]> fixtures() throws Exception { BlobStore shortIdBlobStore = mock(BlobStore.class); when(shortIdBlobStore.writeBlob(any())).thenReturn("shortId"); BlobStore longIdBlobStore = mock(BlobStore.class); when(longIdBlobStore.writeBlob(any())).thenReturn(Strings.repeat("shortId", 1000)); return newArrayList( new Object[]{null, "No BlobStore"}, new Object[]{shortIdBlobStore, "Short Id BlobStore"}, new Object[]{longIdBlobStore, "Long Id BlobStore"}); }
@Override public ArrayBasedBlob createBlob(InputStream in) { try { String id = blobStore.writeBlob(in); return new TestBlob(id, blobStore); } catch(Exception e) { log.error("Error in createBlobs", e); } return null; }
private Blob blobOf(String content, BlobStore bs) throws IOException { String id = bs.writeBlob(new ByteArrayInputStream(content.getBytes())); return new BlobStoreBlob(bs, id); }
public String write(InputStream in) throws DocumentStoreException { try { return nodeStore.getBlobStore().writeBlob(in); } catch (Exception e) { throw new DocumentStoreException(e); } }
private void testBlobIdWithLength(int blobIdLength) throws Exception { String blobId = Strings.repeat("x", blobIdLength); long blobLength = SegmentTestConstants.MEDIUM_LIMIT; doReturn(blobId).when(blobStore).writeBlob(any(InputStream.class)); doReturn(blobLength).when(blobStore).getBlobLength(blobId); SegmentBlob blob = new SegmentBlob(blobStore, fileStore.getWriter().writeStream(newRandomInputStream(blobLength))); assertEquals(blobLength, blob.length()); }
@Test(expected = UnsupportedOperationException.class) public void writingBinariesIsNotSupported() throws IOException { given: { final BlobStore blobStore = new LoopbackBlobStore(); when: { final String test = "Test"; blobStore.writeBlob(adaptToUtf8InputStream(test)); } } }
@Test public void fileDataStore() throws Exception{ String[] args = {"--fds-path", temporaryFolder.getRoot().getAbsolutePath(), "--read-write"}; try (BlobStoreFixture fixture = BlobStoreFixtureProvider.create(createFDSOptions(args))){ String blobId = fixture.getBlobStore().writeBlob(new ByteArrayInputStream("foo".getBytes())); assertNotNull(blobId); } }
@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); } } }
@Test public void blobStoreBlob() throws Exception{ Blob b = new ArrayBasedBlob("hello world".getBytes()); String value = blobStore.writeBlob(b.getNewStream()); String serValue = serializer.serialize(new BlobStoreBlob(blobStore, value)); Blob b2 = serializer.deserialize(serValue); assertTrue(AbstractBlob.equal(b, b2)); }