Search in sources :

Example 1 with JournalWriter

use of alluxio.master.journal.JournalWriter in project alluxio by Alluxio.

the class JournalIntegrationTest method multipleFlush.

/**
   * Tests flushing the journal multiple times, without writing any data.
   */
@Test
public void multipleFlush() throws Exception {
    // Set the max log size to 0 to force a flush to write a new file.
    String existingMax = Configuration.get(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX);
    Configuration.set(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, "0");
    try {
        String journalFolder = mLocalAlluxioCluster.getMaster().getJournalFolder();
        ReadWriteJournal journal = new ReadWriteJournal(PathUtils.concatPath(journalFolder, Constants.FILE_SYSTEM_MASTER_NAME));
        JournalWriter writer = journal.getNewWriter();
        writer.getCheckpointOutputStream(0).close();
        // Flush multiple times, without writing to the log.
        writer.flushEntryStream();
        writer.flushEntryStream();
        writer.flushEntryStream();
        UnderFileStatus[] paths = UnderFileSystem.Factory.get(journalFolder).listStatus(journal.getCompletedDirectory());
        // Make sure no new empty files were created.
        Assert.assertTrue(paths == null || paths.length == 0);
    } finally {
        // Reset the max log size.
        Configuration.set(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, existingMax);
    }
}
Also used : ReadWriteJournal(alluxio.master.journal.ReadWriteJournal) JournalWriter(alluxio.master.journal.JournalWriter) UnderFileStatus(alluxio.underfs.UnderFileStatus) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

JournalWriter (alluxio.master.journal.JournalWriter)1 ReadWriteJournal (alluxio.master.journal.ReadWriteJournal)1 UnderFileStatus (alluxio.underfs.UnderFileStatus)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1