@Override public long length() { try { return blobStore.getBlobLength(blobId); } catch (IOException e) { throw new IllegalArgumentException("Invalid blob id: " + blobId, e); } }
@Override public long length() { try { return blobStore.getBlobLength(blobId); } catch (IOException e) { throw new IllegalArgumentException("Invalid blob id: " + blobId, e); } }
@Override public long length() { try { return blobStore.getBlobLength(blobId); } catch (IOException e) { throw new IllegalArgumentException("Invalid blob id: " + blobId, e); } }
@Override public long getBlobLength(String blobId) { if (store == null) { return -1L; } try { return store.getBlobLength(blobId); } catch (IOException e) { log.warn("Error while reading blob content", e); } return -1L; } }
@Override public long getBlobLength(String blobId) throws IOException { return chooseBlobStoreByBlobId(blobId).getBlobLength(blobId); }
@Override public long getBlobLength(String blobId) throws IOException { return chooseBlobStoreByBlobId(blobId).getBlobLength(blobId); }
@Override public long getBlobLength(String blobId) throws IOException { return chooseBlobStoreByBlobId(blobId).getBlobLength(blobId); }
public long getLength(String blobId) throws MicroKernelException { if (rep == null) { throw new IllegalStateException("this instance has already been disposed"); } try { return rep.getBlobStore().getBlobLength(blobId); } catch (Exception e) { throw new MicroKernelException(e); } }
@Override public long length() { try { return blobStore.getBlobLength(id); } catch (IOException e) { log.error("Error in length", e); } return 0; } }
public static byte[] readFully(BlobStore store, String id) throws IOException { int len = (int) store.getBlobLength(id); byte[] buff = new byte[len]; BlobStoreInputStream in = new BlobStoreInputStream(store, id, 0); IOUtils.readFully(in, buff, 0, len); return buff; }
public static byte[] readFully(BlobStore store, String id) throws IOException { int len = (int) store.getBlobLength(id); byte[] buff = new byte[len]; BlobStoreInputStream in = new BlobStoreInputStream(store, id, 0); IOUtils.readFully(in, buff, 0, len); return buff; }
public static byte[] readFully(BlobStore store, String id) throws IOException { int len = (int) store.getBlobLength(id); byte[] buff = new byte[len]; BlobStoreInputStream in = new BlobStoreInputStream(store, id, 0); IOUtils.readFully(in, buff, 0, len); return buff; }
@Test public void testLength() throws IOException { for (String id : oldBlobIds) { assertEquals(LENGTH, splitBlobStore.getBlobLength(id)); } for (String id : newBlobIds) { assertEquals(LENGTH, newBlobStore.getBlobLength(id)); assertEquals(LENGTH, splitBlobStore.getBlobLength(id)); } }
@Test(expected = NullPointerException.class) public void getBlobLengthShouldAlwaysThrowAnExceptionWhenNullBlobIdIsPassed() throws IOException { given: { final BlobStore store = new LoopbackBlobStore(); when: { store.getBlobLength(null); } } }
public long getLength(String blobId) throws DocumentStoreException { try { return nodeStore.getBlobStore().getBlobLength(blobId); } catch (Exception e) { throw new DocumentStoreException(e); } }
@Test @Parameters(method = "blobIds") public void getBlobLengthShouldAlwaysReturnRealLengthOfBlobThatWillBeReturned( final String blobId) throws IOException { given: { final BlobStore store = new LoopbackBlobStore(); expect: { assertEquals(blobId.getBytes().length, store.getBlobLength(blobId)); } } }
@Test public void shouldReturnBlobContent() throws Exception { BlobStore s = mock(BlobStore.class); when(s.getInputStream("id")).thenReturn(new ByteArrayInputStream(new byte[]{1, 2, 3})); when(s.getBlobLength("id")).thenReturn(3L); DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s); assertEquals(3, r.getBlobLength("id")); assertArrayEquals(new byte[]{1, 2, 3}, IOUtils.toByteArray(r.readBlob("id"))); }
@Test public void shouldReturnNegativeLengthIfBlobIsUnreadable() throws Exception { BlobStore s = mock(BlobStore.class); when(s.getBlobLength("id")).thenReturn(-1L); DefaultStandbyBlobReader r = new DefaultStandbyBlobReader(s); assertEquals(-1L, r.getBlobLength("id")); }
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()); }