protected void cleanAndCompact(int startIndex, int endIndex) { for (int i = startIndex; i <= endIndex; i++) { log.clean(i); } log.compactor().compact(Compaction.MAJOR).join(); }
@BeforeMethod void setLog() throws Exception { logId = UUID.randomUUID().toString(); log = createLog(); assertTrue(log.isOpen()); assertFalse(log.isClosed()); assertTrue(log.isEmpty()); }
@AfterMethod protected void deleteLog() { try { if (log.isOpen()) log.close(); } catch (Exception ignore) { } finally { assertFalse(log.isOpen()); assertTrue(log.isClosed()); log.delete(); } }
/** * Appends {@code numEntries} increasingly numbered ByteBuffer wrapped entries to the log, * starting at the {@code startingId}. */ protected List<Long> appendEntries(int numEntries, int startingId, Compaction.Mode mode) { List<Integer> entryIds = IntStream.range(startingId, startingId + numEntries).boxed().collect(Collectors.toList()); return entryIds .stream() .map( entryId -> { try (TestEntry entry = log.create(TestEntry.class)) { entry.setTerm(1).setCompactionMode(mode).setPadding(entryPadding); return log.append(entry); } }) .collect(Collectors.toList()); }
protected void printLog() { for (int i = 1; i < log.length(); i++) { System.out.println(log.get(i).toString()); } }
protected void assertCompacted(int startIndex, int endIndex) { for (int i = startIndex; i <= endIndex; i++) { assertNull(log.get(i)); } }
/** Appends {@code numEntries} increasingly numbered ByteBuffer wrapped entries to the log. */ protected List<Long> appendEntries(int numEntries, Compaction.Mode mode) { return appendEntries(numEntries, (int) log.length() + 1, mode); }
/** Appends {@code numEntries} increasingly numbered ByteBuffer wrapped entries to the log. */ protected List<Long> appendEntries(int numEntries) { return appendEntries(numEntries, (int) log.length() + 1, Compaction.Mode.QUORUM); }