@Override public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { int count = 0; if (delegate instanceof MultiDataStoreAware) { List<String> deleted = Lists.newArrayListWithExpectedSize(512); for (String chunkId : chunkIds) { String blobId = extractBlobId(chunkId); DataIdentifier identifier = new DataIdentifier(blobId); DataRecord dataRecord = getRecordForId(identifier); boolean success = (maxLastModifiedTime <= 0) || dataRecord.getLastModified() <= maxLastModifiedTime; log.trace("Deleting blob [{}] with last modified date [{}] : [{}]", blobId, dataRecord.getLastModified(), success); if (success) { ((MultiDataStoreAware) delegate).deleteRecord(identifier); deleted.add(blobId); count++; if (count % 512 == 0) { log.info("Deleted blobs {}", deleted); deleted.clear(); } } } if (!deleted.isEmpty()) { log.info("Deleted blobs {}", deleted); } } return count; }
@Override public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { int count = 0; if (delegate instanceof MultiDataStoreAware) { List<String> deleted = Lists.newArrayListWithExpectedSize(512); for (String chunkId : chunkIds) { String blobId = extractBlobId(chunkId); DataIdentifier identifier = new DataIdentifier(blobId); DataRecord dataRecord = getRecordForId(identifier); boolean success = (maxLastModifiedTime <= 0) || dataRecord.getLastModified() <= maxLastModifiedTime; log.trace("Deleting blob [{}] with last modified date [{}] : [{}]", blobId, dataRecord.getLastModified(), success); if (success) { ((MultiDataStoreAware) delegate).deleteRecord(identifier); deleted.add(blobId); count++; if (count % 512 == 0) { log.info("Deleted blobs {}", deleted); deleted.clear(); } } } if (!deleted.isEmpty()) { log.info("Deleted blobs {}", deleted); } } return count; }
@Override public long countDeleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { int count = 0; if (delegate instanceof MultiDataStoreAware) { List<String> deleted = Lists.newArrayListWithExpectedSize(512); for (String chunkId : chunkIds) { String blobId = extractBlobId(chunkId); DataIdentifier identifier = new DataIdentifier(blobId); DataRecord dataRecord = getRecordForId(identifier); boolean success = (maxLastModifiedTime <= 0) || dataRecord.getLastModified() <= maxLastModifiedTime; log.trace("Deleting blob [{}] with last modified date [{}] : [{}]", blobId, dataRecord.getLastModified(), success); if (success) { ((MultiDataStoreAware) delegate).deleteRecord(identifier); deleted.add(blobId); count++; if (count % 512 == 0) { log.info("Deleted blobs {}", deleted); deleted.clear(); } } } if (!deleted.isEmpty()) { log.info("Deleted blobs {}", deleted); } } return count; }
@Test public void testGetRecordForId() throws Exception { File rootFolder = folder.newFolder(); dataStore = getBlobStore(rootFolder); int number = 10; Set<DataRecord> added = newHashSet(); for (int i = 0; i < number; i++) { added.add(dataStore.addRecord(randomStream(i, 16516))); } Set<DataRecord> retrieved = newHashSet(); for (DataRecord rec : added) { retrieved.add(dataStore.getRecordForId(rec.getIdentifier())); } assertRecords(added, retrieved); }