* @param info The Master Info
* @param path The path of the edit log
* @throws IOException
*/
public static void loadSingleLog(MasterInfo info, String path) throws IOException {
UnderFileSystem ufs = UnderFileSystem.get(path);
DataInputStream is = new DataInputStream(ufs.open(path));
JsonParser parser = JsonObject.createObjectMapper().getFactory().createParser(is);
while (true) {
EditLogOperation op;
try {
op = parser.readValueAs(EditLogOperation.class);
LOG.debug("Read operation: {}", op);
} catch (IOException e) {
// Unfortunately brittle, but Jackson rethrows EOF with this message.
if (e.getMessage().contains("end-of-input")) {
break;
} else {
throw e;
}
}
sCurrentTId = op.mTransId;
try {
switch (op.mType) {
case ADD_BLOCK: {
info.opAddBlock(op.getInt("fileId"), op.getInt("blockIndex"),
op.getLong("blockLength"), op.getLong("opTimeMs"));
break;
}
case ADD_CHECKPOINT: {
info._addCheckpoint(-1, op.getInt("fileId"), op.getLong("length"),
new TachyonURI(op.getString("path")), op.getLong("opTimeMs"));
break;
}
case CREATE_FILE: {
info._createFile(op.getBoolean("recursive"), new TachyonURI(op.getString("path")),
op.getBoolean("directory"), op.getLong("blockSizeByte"),
op.getLong("creationTimeMs"));
break;
}
case COMPLETE_FILE: {
info._completeFile(op.get("fileId", Integer.class), op.getLong("opTimeMs"));
break;
}
case SET_PINNED: {
info._setPinned(op.getInt("fileId"), op.getBoolean("pinned"), op.getLong("opTimeMs"));
break;
}
case RENAME: {
info._rename(op.getInt("fileId"), new TachyonURI(op.getString("dstPath")),
op.getLong("opTimeMs"));
break;
}
case DELETE: {
info._delete(op.getInt("fileId"), op.getBoolean("recursive"), op.getLong("opTimeMs"));
break;
}
case CREATE_RAW_TABLE: {
info._createRawTable(op.getInt("tableId"), op.getInt("columns"),
op.getByteBuffer("metadata"));
break;
}
case UPDATE_RAW_TABLE_METADATA: {
info.updateRawTableMetadata(op.getInt("tableId"), op.getByteBuffer("metadata"));
break;
}
case CREATE_DEPENDENCY: {
info._createDependency(op.get("parents", new TypeReference<List<Integer>>() {}),
op.get("children", new TypeReference<List<Integer>>() {}),
op.getString("commandPrefix"), op.getByteBufferList("data"),
op.getString("comment"), op.getString("framework"),
op.getString("frameworkVersion"), op.get("dependencyType", DependencyType.class),
op.getInt("dependencyId"), op.getLong("creationTimeMs"));
break;
}
default:
throw new IOException("Invalid op type " + op);
}
} catch (SuspectedFileSizeException e) {
throw new IOException(e);
} catch (BlockInfoException e) {
throw new IOException(e);
} catch (FileDoesNotExistException e) {
throw new IOException(e);
} catch (FileAlreadyExistException e) {
throw new IOException(e);
} catch (InvalidPathException e) {
throw new IOException(e);
} catch (TachyonException e) {
throw new IOException(e);
} catch (TableDoesNotExistException e) {
throw new IOException(e);
}
}
is.close();
ufs.close();
}