Example usage for org.apache.zookeeper.server.util SerializeUtils deserializeSnapshot

List of usage examples for org.apache.zookeeper.server.util SerializeUtils deserializeSnapshot

Introduction

In this page you can find the example usage for org.apache.zookeeper.server.util SerializeUtils deserializeSnapshot.

Prototype

public static void deserializeSnapshot(DataTree dt, InputArchive ia, Map<Long, Integer> sessions)
            throws IOException 

Source Link

Usage

From source file:com.linkedin.helix.tools.ZKLogFormatter.java

License:Apache License

private static void readSnapshotLog(String snapshotPath) throws Exception {
    FileInputStream fis = new FileInputStream(snapshotPath);
    BinaryInputArchive ia = BinaryInputArchive.getArchive(fis);
    Map<Long, Integer> sessions = new HashMap<Long, Integer>();
    DataTree dt = new DataTree();
    FileHeader header = new FileHeader();
    header.deserialize(ia, "fileheader");
    if (header.getMagic() != FileSnap.SNAP_MAGIC) {
        throw new IOException("mismatching magic headers " + header.getMagic() + " !=  " + FileSnap.SNAP_MAGIC);
    }/* ww  w.ja v a  2 s .com*/
    SerializeUtils.deserializeSnapshot(dt, ia, sessions);

    if (bw != null) {
        bw.write(sessions.toString());
        bw.newLine();
    } else {
        System.out.println(sessions);
    }
    traverse(dt, 1, "/");

}