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