@Override public boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { return (chunkIds.size() == countDeleteChunks(chunkIds, maxLastModifiedTime)); }
@Override public boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { return (chunkIds.size() == countDeleteChunks(chunkIds, maxLastModifiedTime)); }
@Override public boolean deleteChunks(List<String> chunkIds, long maxLastModifiedTime) throws Exception { return (chunkIds.size() == countDeleteChunks(chunkIds, maxLastModifiedTime)); }
@Test public void consistencyCheckWithRenegadeDelete() throws Exception { DataStoreState state = setUp(); // Simulate faulty state by deleting some blobs directly Random rand = new Random(87); List<String> existing = Lists.newArrayList(state.blobsPresent); long count = blobStore.countDeleteChunks(ImmutableList.of(existing.get(rand.nextInt(existing.size()))), 0); ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10); MarkSweepGarbageCollector gcObj = init(86400, executor); long candidates = gcObj.checkConsistency(); assertEquals(1, executor.getTaskCount()); assertEquals(count, candidates); }
@Test public void testConsistencyWithDeleteTracker() throws Exception { File dump = temporaryFolder.newFolder(); File repoHome = temporaryFolder.newFolder(); File trackerFolder = new File(repoHome, "blobids"); FileUtils.forceMkdir(trackerFolder); File delTracker = new File(trackerFolder, "activedeletions.del"); Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); String activeDeletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(activeDeletedBlobId); count += setupDataStore.countDeleteChunks(ImmutableList.of(activeDeletedBlobId), 0); assertEquals(2, count); // artificially put the deleted id in the tracked .del file FileIOUtils.writeStrings(Iterators.singletonIterator(activeDeletedBlobId), delTracker, false); setupDataStore.close(); testAllParams(dump, repoHome); assertFileEquals(dump, "[id]", blobsAdded); assertFileEquals(dump, "[ref]", Sets.union(blobsAdded, Sets.newHashSet(deletedBlobId, activeDeletedBlobId))); assertFileEquals(dump, "[consistency]", Sets.newHashSet(deletedBlobId)); }
@Test public void testConsistency() throws Exception { File dump = temporaryFolder.newFolder(); File repoHome = temporaryFolder.newFolder(); Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); assertEquals(1, count); setupDataStore.close(); testAllParams(dump, repoHome); assertFileEquals(dump, "[id]", blobsAdded); assertFileEquals(dump, "[ref]", Sets.union(blobsAdded, Sets.newHashSet(deletedBlobId))); assertFileEquals(dump, "[consistency]", Sets.newHashSet(deletedBlobId)); }
@Test public void testConsistencyVerboseWithDeleteTracker() throws Exception { File dump = temporaryFolder.newFolder(); File repoHome = temporaryFolder.newFolder(); File trackerFolder = new File(repoHome, "blobids"); FileUtils.forceMkdir(trackerFolder); File delTracker = new File(trackerFolder, "activedeletions.del"); Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); long count = setupDataStore.countDeleteChunks(ImmutableList.of(deletedBlobId), 0); String activeDeletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(activeDeletedBlobId); count += setupDataStore.countDeleteChunks(ImmutableList.of(activeDeletedBlobId), 0); assertEquals(2, count); // artificially put the deleted id in the tracked .del file FileIOUtils.writeStrings(Iterators.singletonIterator(activeDeletedBlobId), delTracker, false); setupDataStore.close(); testAllParamsVerbose(dump, repoHome); assertFileEquals(dump, "[id]", encodedIds(blobsAdded, dsOption)); assertFileEquals(dump, "[ref]", encodedIdsAndPath(Sets.union(blobsAdded, Sets.newHashSet(deletedBlobId, activeDeletedBlobId)), dsOption, blobsAddedWithNodes)); assertFileEquals(dump, "[consistency]", encodedIdsAndPath(Sets.newHashSet(deletedBlobId), dsOption, blobsAddedWithNodes)); }
@Test public void testConsistencyVerbose() throws Exception { File dump = temporaryFolder.newFolder(); File repoHome = temporaryFolder.newFolder(); Random rand = new Random(); String deletedBlobId = Iterables.get(blobsAdded, rand.nextInt(blobsAdded.size())); blobsAdded.remove(deletedBlobId); long count = setupDataStore .countDeleteChunks(ImmutableList.of(deletedBlobId), 0); assertEquals(1, count); setupDataStore.close(); testAllParamsVerbose(dump, repoHome); assertFileEquals(dump, "[id]", encodedIds(blobsAdded, dsOption)); assertFileEquals(dump, "[ref]", encodedIdsAndPath(Sets.union(blobsAdded, Sets.newHashSet(deletedBlobId)), dsOption, blobsAddedWithNodes)); assertFileEquals(dump, "[consistency]", encodedIdsAndPath(Sets.newHashSet(deletedBlobId), dsOption, blobsAddedWithNodes)); }
long count = blobStore.countDeleteChunks(ImmutableList.of(id), 0); assertEquals(1, count);