use of alluxio.master.journal.checkpoint.CheckpointOutputStream in project alluxio by Alluxio.
the class JournalUtilsTest method restoreInvalidJournalEntryCheckpoint.
@Test
public void restoreInvalidJournalEntryCheckpoint() throws IOException {
Journaled journaled = new TestJournaled(0);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Checkpoint version doesn't match Constants.JOURNAL_ENTRY_CHECKPOINT_VERSION.
CheckpointOutputStream cos = new CheckpointOutputStream(baos, CheckpointType.COMPOUND);
cos.flush();
mThrown.expect(IllegalStateException.class);
mThrown.expectMessage("Unrecognized checkpoint type");
JournalUtils.restoreJournalEntryCheckpoint(new CheckpointInputStream(new ByteArrayInputStream(baos.toByteArray())), journaled);
}
use of alluxio.master.journal.checkpoint.CheckpointOutputStream in project alluxio by Alluxio.
the class JournalUtils method writeJournalEntryCheckpoint.
/**
* Writes a checkpoint of the entries in the given iterable.
*
* This is the complement of
* {@link #restoreJournalEntryCheckpoint(CheckpointInputStream, Journaled)}.
*
* @param output the stream to write to
* @param iterable the iterable for fetching journal entries
*/
public static void writeJournalEntryCheckpoint(OutputStream output, JournalEntryIterable iterable) throws IOException, InterruptedException {
output = new CheckpointOutputStream(output, CheckpointType.JOURNAL_ENTRY);
try (CloseableIterator<JournalEntry> it = iterable.getJournalEntryIterator()) {
LOG.info("Write journal entry checkpoint");
while (it.get().hasNext()) {
if (Thread.interrupted()) {
throw new InterruptedException();
}
it.get().next().writeDelimitedTo(output);
}
}
output.flush();
}
use of alluxio.master.journal.checkpoint.CheckpointOutputStream in project alluxio by Alluxio.
the class JournalUtils method writeToCheckpoint.
/**
* Writes a composite checkpoint for the given checkpointed components.
*
* This is the complement of {@link #restoreFromCheckpoint(CheckpointInputStream, List)}.
*
* @param output the stream to write to
* @param components the components to checkpoint
*/
public static void writeToCheckpoint(OutputStream output, List<? extends Checkpointed> components) throws IOException, InterruptedException {
OutputChunked chunked = new OutputChunked(new CheckpointOutputStream(output, CheckpointType.COMPOUND), 64 * Constants.KB);
for (Checkpointed component : components) {
chunked.writeString(component.getCheckpointName().toString());
component.writeToCheckpoint(chunked);
chunked.endChunks();
}
chunked.flush();
}
use of alluxio.master.journal.checkpoint.CheckpointOutputStream in project alluxio by Alluxio.
the class InodeCounter method writeToCheckpoint.
@Override
public void writeToCheckpoint(OutputStream output) throws IOException, InterruptedException {
CheckpointOutputStream stream = new CheckpointOutputStream(output, CheckpointType.LONG);
stream.writeLong(longValue());
stream.flush();
}
use of alluxio.master.journal.checkpoint.CheckpointOutputStream in project alluxio by Alluxio.
the class RocksStore method writeToCheckpoint.
/**
* Writes a checkpoint of the database's content to the given output stream.
*
* @param output the stream to write to
*/
public synchronized void writeToCheckpoint(OutputStream output) throws IOException, InterruptedException {
LOG.info("Creating rocksdb checkpoint at {}", mDbCheckpointPath);
long startNano = System.nanoTime();
CheckpointOutputStream out = new CheckpointOutputStream(output, CheckpointType.ROCKS);
try {
// createCheckpoint requires that the directory not already exist.
FileUtils.deletePathRecursively(mDbCheckpointPath);
mCheckpoint.createCheckpoint(mDbCheckpointPath);
} catch (RocksDBException e) {
throw new IOException(e);
}
LOG.info("Checkpoint complete, creating tarball");
TarUtils.writeTarGz(Paths.get(mDbCheckpointPath), out);
LOG.info("Completed rocksdb checkpoint in {}ms", (System.nanoTime() - startNano) / 1_000_000);
// Checkpoint is no longer needed, delete to save space.
FileUtils.deletePathRecursively(mDbCheckpointPath);
}
Aggregations