use of alluxio.master.journal.checkpoint.CompoundCheckpointFormat.CompoundCheckpointReader.Entry in project alluxio by Alluxio.
the class JournalUtils method restoreFromCheckpoint.
/**
* Restores the given checkpointed components from a composite checkpoint.
*
* This is the complement of {@link #writeToCheckpoint(OutputStream, List)}.
*
* @param input the stream to read from
* @param components the components to restore
*/
public static void restoreFromCheckpoint(CheckpointInputStream input, List<? extends Checkpointed> components) throws IOException {
CompoundCheckpointReader reader = new CompoundCheckpointReader(input);
Optional<Entry> next;
while ((next = reader.nextCheckpoint()).isPresent()) {
Entry nextEntry = next.get();
boolean found = false;
for (Checkpointed component : components) {
if (component.getCheckpointName().equals(nextEntry.getName())) {
component.restoreFromCheckpoint(nextEntry.getStream());
found = true;
break;
}
}
if (!found) {
throw new RuntimeException(String.format("Unrecognized checkpoint name: %s. Existing components: %s", nextEntry.getName(), Arrays.toString(StreamUtils.map(Checkpointed::getCheckpointName, components).toArray())));
}
}
}
use of alluxio.master.journal.checkpoint.CompoundCheckpointFormat.CompoundCheckpointReader.Entry in project alluxio by Alluxio.
the class CompoundCheckpointFormat method parseToHumanReadable.
@Override
public void parseToHumanReadable(CheckpointInputStream in, PrintStream out) throws IOException {
CompoundCheckpointReader reader = createReader(in);
Optional<Entry> entryOpt;
while ((entryOpt = reader.nextCheckpoint()).isPresent()) {
Entry entry = entryOpt.get();
out.printf("--- Begin checkpoint for %s ---%n", entry.getName());
CheckpointFormat format = entry.getStream().getType().getCheckpointFormat();
format.parseToHumanReadable(entry.getStream(), out);
out.printf("--- End checkpoint for %s ---%n", entry.getName());
}
}
Aggregations