private void gcWithTtl() throws InterruptedException, IOException { // Wait for the system clock to move by at least 1 millisecond. // This allows the DfsGarbageCollector to recognize the boundary. long start = System.currentTimeMillis(); do { Thread.sleep(10); } while (System.currentTimeMillis() <= start); DfsGarbageCollector gc = new DfsGarbageCollector(repo); gc.setGarbageTtl(1, TimeUnit.MILLISECONDS); run(gc); }
@Test public void testCollectionWithGarbageNoCoalescence() throws Exception { RevCommit commit0 = commit().message("0").create(); RevCommit commit1 = commit().message("1").parent(commit0).create(); git.update("master", commit0); for (int i = 0; i < 3; i++) { commit1 = commit().message("g" + i).parent(commit1).create(); DfsGarbageCollector gc = new DfsGarbageCollector(repo); gc.setCoalesceGarbageLimit(0); gc.setGarbageTtl(0, TimeUnit.MILLISECONDS); run(gc); assertEquals(1 + i, countPacks(UNREACHABLE_GARBAGE)); } }
private void run(DfsGarbageCollector gc) throws IOException { assertTrue("gc repacked", gc.pack(null)); odb.clearCache(); }
private void gcNoTtl() throws IOException { DfsGarbageCollector gc = new DfsGarbageCollector(repo); gc.setGarbageTtl(0, TimeUnit.MILLISECONDS); // disable TTL run(gc); }