@Override public JournalFile getJournalFile() { return new AzureJournalFile(segmentstoreDirectory, "journal.log"); }
@Override public boolean exists() { try { return !getJournalBlobs().isEmpty(); } catch (IOException e) { log.error("Can't check if the file exists", e); return false; } }
@Test public void testSplitJournalFiles() throws IOException { assertFalse(journal.exists()); JournalFileWriter writer = journal.openJournalWriter(); for (int i = 0; i < 100; i++) { writer.writeLine("line " + i); } assertTrue(journal.exists()); writer = journal.openJournalWriter(); for (int i = 100; i < 200; i++) { writer.writeLine("line " + i); } JournalFileReader reader = journal.openJournalReader(); for (int i = 199; i >= 0; i--) { assertEquals("line " + i, reader.readLine()); } }
@Test public void testTruncateJournalFile() throws IOException { assertFalse(journal.exists()); JournalFileWriter writer = journal.openJournalWriter(); for (int i = 0; i < 100; i++) { writer.writeLine("line " + i); } assertTrue(journal.exists()); writer.truncate(); assertTrue(journal.exists()); } }
@Override public JournalFile getJournalFile() { return new AzureJournalFile(segmentstoreDirectory, "journal.log"); }
@Override public boolean exists() { try { return !getJournalBlobs().isEmpty(); } catch (IOException e) { log.error("Can't check if the file exists", e); return false; } }
protected JournalReader createJournalReader(String s) throws IOException { try { CloudAppendBlob blob = container.getAppendBlobReference("journal/journal.log.001"); blob.createOrReplace(); blob.appendText(s); return new JournalReader(new AzureJournalFile(container.getDirectoryReference("journal"), "journal.log")); } catch (StorageException | URISyntaxException e) { throw new IOException(e); } } }
@Override public JournalFileReader openJournalReader() throws IOException { return new CombinedReader(getJournalBlobs()); }
@Before public void setup() throws StorageException, InvalidKeyException, URISyntaxException { container = azurite.getContainer("oak-test"); journal = new AzureJournalFile(container.getDirectoryReference("journal"), "journal.log", 10); }
@Override public JournalFileReader openJournalReader() throws IOException { return new CombinedReader(getJournalBlobs()); }