public long getSize() { try { return getDataRecord().getLength(); } catch (DataStoreException e) { log.warn("getSize for " + identifier + " failed", e); return -1; } }
public long getSize() { try { return getDataRecord().getLength(); } catch (DataStoreException e) { log.warn("getSize for " + identifier + " failed", e); return -1; } }
private void addNewMapping(DataRecord dr) throws DataStoreException { if (dr != null) { newMappings.put(dr.getIdentifier().toString(), dr.getLength()); } }
private void addNewMapping(DataRecord dr) throws DataStoreException { if (dr != null) { newMappings.put(dr.getIdentifier().toString(), dr.getLength()); } }
BlobId(DataRecord dr) { this.blobId = dr.getIdentifier().toString(); long len; try { len = dr.getLength(); } catch (DataStoreException e) { //Cannot determine length len = -1; } this.length = len; }
static BLOBInDataStore getInstance(DataStore store, InputStream in) throws DataStoreException { DataRecord rec = store.addRecord(in); DataIdentifier identifier = rec.getIdentifier(); if (auditLogger.isDebugEnabled()) { auditLogger.debug("{} ({})", identifier, rec.getLength()); } return new BLOBInDataStore(store, identifier); }
BlobId(DataRecord dr) { this.blobId = dr.getIdentifier().toString(); long len; try { len = dr.getLength(); } catch (DataStoreException e) { //Cannot determine length len = -1; } this.length = len; }
@Override public long getBlobLength(String encodedBlobId) throws IOException { try { checkNotNull(encodedBlobId, "BlobId must be specified"); BlobId id = BlobId.of(encodedBlobId); if (encodeLengthInId && id.hasLengthInfo()) { return id.length; } return getDataRecord(id.blobId).getLength(); } catch (DataStoreException e) { throw new IOException(e); } }
static BLOBInDataStore getInstance(DataStore store, InputStream in) throws DataStoreException { DataRecord rec = store.addRecord(in); DataIdentifier identifier = rec.getIdentifier(); if (auditLogger.isDebugEnabled()) { auditLogger.debug("{} ({})", identifier, rec.getLength()); } return new BLOBInDataStore(store, identifier); }
@Override public long getBlobLength(String encodedBlobId) throws IOException { try { checkNotNull(encodedBlobId, "BlobId must be specified"); BlobId id = BlobId.of(encodedBlobId); if (encodeLengthInId && id.hasLengthInfo()) { return id.length; } return getDataRecord(id.blobId).getLength(); } catch (DataStoreException e) { throw new IOException(e); } }
@Override public long getBlobLength(String encodedBlobId) throws IOException { try { checkNotNull(encodedBlobId, "BlobId must be specified"); BlobId id = BlobId.of(encodedBlobId); if (encodeLengthInId && id.hasLengthInfo()) { return id.length; } return getDataRecord(id.blobId).getLength(); } catch (DataStoreException e) { throw new IOException(e); } }
BlobId(DataRecord dr) { this.blobId = dr.getIdentifier().toString(); long len; try { len = dr.getLength(); } catch (DataStoreException e) { //Cannot determine length len = -1; } this.length = len; }
@Override public long getLength() throws DataStoreException { Long size = mapping.get(getIdentifier().toString()); if (size == null) { log.info("No size mapping found for {}. Checking with delegate", getIdentifier()); return getDelegateRecord().getLength(); } return size; }
@Override public long getLength() throws DataStoreException { Long size = mapping.get(getIdentifier().toString()); if (size == null) { log.info("No size mapping found for {}. Checking with delegate", getIdentifier()); return getDelegateRecord().getLength(); } return size; }
/** * Test {@link DataStore#addRecord(InputStream)} and assert length of added * record. */ protected void doAddRecordTest() throws Exception { byte[] data = new byte[dataLength]; randomGen.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); Assert.assertEquals(data.length, rec.getLength()); assertRecord(data, rec); }
/** * Test {@link DataStore#getRecord(DataIdentifier)} and assert length and * inputstream. */ protected void doGetRecordTest() throws Exception { byte[] data = new byte[dataLength]; randomGen.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); rec = ds.getRecord(rec.getIdentifier()); Assert.assertEquals(data.length, rec.getLength()); assertRecord(data, rec); }
/** * Test {@link DataStore#addRecord(InputStream)} and assert length of added * record. */ protected void doAddRecordTest() throws Exception { ds = createDataStore(); byte[] data = new byte[dataLength]; randomGen.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); assertEquals(data.length, rec.getLength()); assertRecord(data, rec); ds.close(); }
private void validateRecord(final DataRecord record, final String contents, final DataIdentifier identifier, final long length, final long lastModified) throws DataStoreException, IOException { validateRecord(record, contents, identifier, length, lastModified, true); }
/** * Test {@link DataStore#getRecord(DataIdentifier)} and assert length and * inputstream. */ protected void doGetRecordTest() throws Exception { ds = createDataStore(); byte[] data = new byte[dataLength]; randomGen.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); rec = ds.getRecord(rec.getIdentifier()); assertEquals(data.length, rec.getLength()); assertRecord(data, rec); ds.close(); }
@Test public void testCreateAndDeleteBlobHappyPath() throws DataStoreException, IOException { final DataRecord uploadedRecord = ds.addRecord(new ByteArrayInputStream(testBuffer)); DataIdentifier identifier = uploadedRecord.getIdentifier(); assertTrue(backend.exists(identifier)); assertTrue(0 != uploadedRecord.getLastModified()); assertEquals(testBuffer.length, uploadedRecord.getLength()); final DataRecord retrievedRecord = ds.getRecord(identifier); validateRecord(retrievedRecord, new String(testBuffer), uploadedRecord); ds.deleteRecord(identifier); assertFalse(backend.exists(uploadedRecord.getIdentifier())); }