@Test public void testGC() throws IOException { assumeFalse("GC not tested in transactional blob store", bp.isTransactional()); String key1 = bs.writeBlob(blobContext(ID1, FOO)); assertKey(ID1, key1); String key2 = bs.writeBlob(blobContext(ID2, "barbaz")); assertKey(ID2, key2); long addNum = 0; long addSize = 0; String key3 = null; if (hasGCTimeThreshold()) { waitForGCTimeThreshold(); key3 = bs.writeBlob(blobContext(ID3, "abcde")); assertKey(ID3, key3); addNum = 1; addSize = 5; } BinaryGarbageCollector gc = bs.getBinaryGarbageCollector(); assertFalse(gc.isInProgress()); gc.start(); assertTrue(gc.isInProgress()); gc.mark(key1); assertTrue(gc.isInProgress()); gc.stop(false); assertFalse(gc.isInProgress()); BinaryManagerStatus status = gc.getStatus(); assertEquals(1 + addNum, status.numBinaries); assertEquals(1, status.numBinariesGC); if (checkSizeOfGCedFiles()) { assertEquals(3 + addSize, status.sizeBinaries); assertEquals(6, status.sizeBinariesGC); } assertBlob(key1, FOO); assertBlob(key2, "barbaz"); assertFalse(gc.isInProgress()); gc.start(); assertTrue(gc.isInProgress()); gc.mark(key1); assertTrue(gc.isInProgress()); gc.stop(true); assertFalse(gc.isInProgress()); status = gc.getStatus(); assertEquals(1 + addNum, status.numBinaries); assertEquals(1, status.numBinariesGC); if (checkSizeOfGCedFiles()) { assertEquals(3 + addSize, status.sizeBinaries); assertEquals(6, status.sizeBinariesGC); } assertBlob(key1, FOO); assertNoBlob(key2); if (hasGCTimeThreshold()) { assertBlob(key3, "abcde"); } }
@Override public String writeBlob(BlobContext blobContext) throws IOException { BlobWriteContext blobWriteContext = keyStrategy.getBlobWriteContext(blobContext); return writeBlob(blobWriteContext); }
AbstractBlobStore implements BlobStore { @Override public String writeBlob(BlobContext blobContext) throws IOException { BlobWriteContext blobWriteContext = keyStrategy.getBlobWriteContext(blobContext); return writeBlob(blobWriteContext); } }
AbstractBlobStore implements BlobStore { @Override public String writeBlob(BlobContext blobContext) throws IOException { BlobWriteContext blobWriteContext = keyStrategy.getBlobWriteContext(blobContext); return writeBlob(blobWriteContext); } AbstractBlobStore(String name, KeyStrategy keyStrategy); }
AbstractBlobStore implements BlobStore { @Override public String writeBlob(BlobContext blobContext) throws IOException { BlobWriteContext blobWriteContext = keyStrategy.getBlobWriteContext(blobContext); return writeBlob(blobWriteContext); } AbstractBlobStore(String name, KeyStrategy keyStrategy); @Override String getName(); @Override boolean hasVersioning(); @Override KeyStrategy getKeyStrategy(); @Override BlobStore unwrap(); @Override String writeBlob(BlobContext blobContext); @Override void writeBlobProperties(BlobUpdateContext blobUpdateContext); @Override void deleteBlob(BlobContext blobContext); @Override boolean copyBlobIsOptimized(BlobStore sourceStore); static String setByteRangeInKey(String key, ByteRange byteRange); static ByteRange getByteRangeFromKey(MutableObject<String> keyHolder); void transfer(BlobWriteContext blobWriteContext, Path dest); void transfer(BlobWriteContext blobWriteContext, OutputStream out); @SuppressWarnings("resource") void transfer(InputStream in, OutputStream out, WriteObserver writeObserver); }
AbstractBlobStore implements BlobStore { @Override public String writeBlob(BlobContext blobContext) throws IOException { BlobWriteContext blobWriteContext = keyStrategy.getBlobWriteContext(blobContext); return writeBlob(blobWriteContext); } AbstractBlobStore(String name, KeyStrategy keyStrategy); @Override String getName(); @Override boolean hasVersioning(); @Override KeyStrategy getKeyStrategy(); @Override BlobStore unwrap(); @Override String writeBlob(BlobContext blobContext); @Override void writeBlobProperties(BlobUpdateContext blobUpdateContext); @Override void deleteBlob(BlobContext blobContext); @Override boolean copyBlobIsOptimized(BlobStore sourceStore); static String setByteRangeInKey(String key, ByteRange byteRange); static ByteRange getByteRangeFromKey(MutableObject<String> keyHolder); void transfer(BlobWriteContext blobWriteContext, Path dest); void transfer(BlobWriteContext blobWriteContext, OutputStream out); @SuppressWarnings("resource") void transfer(InputStream in, OutputStream out, WriteObserver writeObserver); static final char BYTE_RANGE_SEP; }