Beispiel #1
0
  protected void cleanAndCompact(int startIndex, int endIndex) {
    for (int i = startIndex; i <= endIndex; i++) {
      log.clean(i);
    }

    log.compactor().compact(Compaction.MAJOR).join();
  }
Beispiel #2
0
 @BeforeMethod
 void setLog() throws Exception {
   logId = UUID.randomUUID().toString();
   log = createLog();
   assertTrue(log.isOpen());
   assertFalse(log.isClosed());
   assertTrue(log.isEmpty());
 }
Beispiel #3
0
 @AfterMethod
 protected void deleteLog() {
   try {
     if (log.isOpen()) log.close();
   } catch (Exception ignore) {
   } finally {
     assertFalse(log.isOpen());
     assertTrue(log.isClosed());
     log.delete();
   }
 }
Beispiel #4
0
 /**
  * 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());
 }
Beispiel #5
0
 protected void printLog() {
   for (int i = 1; i < log.length(); i++) {
     System.out.println(log.get(i).toString());
   }
 }
Beispiel #6
0
 protected void assertCompacted(int startIndex, int endIndex) {
   for (int i = startIndex; i <= endIndex; i++) {
     assertNull(log.get(i));
   }
 }
Beispiel #7
0
 /** 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);
 }
Beispiel #8
0
 /** 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);
 }