BlobGC extends AnnotatedStandardMBean implements BlobGCMBean { @Override public CompositeData checkConsistency() { if (consistencyOp.isDone()) { consistencyOp = newManagementOperation(CONSISTENCY_OP_NAME, new Callable<String>() { @Override public String call() throws Exception { long t0 = nanoTime(); long missing = blobGarbageCollector.checkConsistency(); return "Consistency check completed in " + formatTime(nanoTime() - t0) + ". " + + missing + " missing blobs found (details in the log)."; } }); executor.execute(consistencyOp); } return getConsistencyCheckStatus(); } BlobGC(
            @NotNull BlobGarbageCollector blobGarbageCollector,
            @NotNull Executor executor); @NotNull @Override CompositeData startBlobGC(final boolean markOnly); @Override CompositeData startBlobGC(final boolean markOnly, final boolean forceBlobIdRetrieve); @NotNull @Override CompositeData getBlobGCStatus(); @Override CompositeData checkConsistency(); @NotNull @Override CompositeData getConsistencyCheckStatus(); @Override TabularData getGlobalMarkStats(); @Override TabularData getOperationStats(); static final String OP_NAME; static final String CONSISTENCY_OP_NAME; }
@Test public void checkConsistency() throws Exception { log.info("Starting checkConsistency()"); long afterSetupTime = clock.getTime(); log.info("after setup time {}", afterSetupTime); MarkSweepGarbageCollector collector = cluster.getCollector(0); long missing = collector.checkConsistency(); assertEquals(0, missing); assertStats(cluster.statsProvider, 1, 0, 0, 0, CONSISTENCY_NAME); assertStatsBean(collector.getConsistencyOperationStats(), 1, 0, 0); }
@Test public void checkConsistencyFailure() throws Exception { log.info("Starting checkConsistencyFailure()"); long afterSetupTime = clock.getTime(); log.info("after setup time {}", afterSetupTime); cluster.blobStore .countDeleteChunks(Lists.newArrayList(Iterators.getLast(cluster.blobStoreState.blobsPresent.iterator())), 0); MarkSweepGarbageCollector collector = cluster.getCollector(0); long missing = collector.checkConsistency(); assertEquals(1, missing); assertStats(cluster.statsProvider, 1, 1, 1, 0, CONSISTENCY_NAME); assertStatsBean(collector.getConsistencyOperationStats(), 1, 1, 1); }
@Test public void checkConsistencyGlobal() throws Exception { log.info("Staring checkConsistencyGlobal()"); MemoryBlobStoreNodeStore secondClusterNodeStore = new MemoryBlobStoreNodeStore(cluster.blobStore, true); Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100); closer.register(secondCluster); secondCluster.blobStoreState.blobsPresent.add(Iterables.firstOf(cluster.blobStoreState.blobsPresent)); executeGarbageCollection(cluster, cluster.getCollector(0), true); MarkSweepGarbageCollector globalCollector = secondCluster.getCollector(0, true, false); long missing = globalCollector.checkConsistency(); assertEquals(0, missing); assertStats(secondCluster.statsProvider, 1, 0, 0, 0, CONSISTENCY_NAME); assertStatsBean(globalCollector.getConsistencyOperationStats(), 1, 0, 0); }
@Test public void checkConsistencyGlobalFailureOther() throws Exception { log.info("Staring checkConsistencyGlobalFailureOther()"); MemoryBlobStoreNodeStore secondClusterNodeStore = new MemoryBlobStoreNodeStore(cluster.blobStore); Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100); closer.register(secondCluster); cluster.blobStore .countDeleteChunks(Lists.newArrayList(Iterators.getLast(cluster.blobStoreState.blobsPresent.iterator())), 0); executeGarbageCollection(cluster, cluster.getCollector(0), true); MarkSweepGarbageCollector globalCollector = secondCluster.getCollector(0, true, false); long missing = globalCollector.checkConsistency(); assertEquals(1, missing); assertStats(secondCluster.statsProvider, 1, 1, 1, 0, CONSISTENCY_NAME); assertStatsBean(globalCollector.getConsistencyOperationStats(), 1, 1, 1); }
@Test public void checkConsistencyGlobalFailure() throws Exception { log.info("Staring checkConsistencyGlobalFailureOther()"); MemoryBlobStoreNodeStore secondClusterNodeStore = new MemoryBlobStoreNodeStore(cluster.blobStore); Cluster secondCluster = new Cluster(folder.newFolder(), cluster.blobStore, secondClusterNodeStore, 100); closer.register(secondCluster); secondCluster.blobStore .countDeleteChunks(Lists.newArrayList(Iterators.getLast(secondCluster.blobStoreState.blobsPresent.iterator())), 0); executeGarbageCollection(cluster, cluster.getCollector(0), true); MarkSweepGarbageCollector globalCollector = secondCluster.getCollector(0, true, false); long missing = globalCollector.checkConsistency(); assertEquals(1, missing); assertStats(secondCluster.statsProvider, 1, 1, 1, 0, CONSISTENCY_NAME); assertStatsBean(globalCollector.getConsistencyOperationStats(), 1, 1, 1); }