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