Class FileSnap
- java.lang.Object
-
- org.apache.zookeeper.server.persistence.FileSnap
-
-
Field Summary
Fields Modifier and Type Field Description static intSNAP_MAGICstatic java.lang.StringSNAPSHOT_FILE_PREFIX
-
Constructor Summary
Constructors Constructor Description FileSnap(java.io.File snapDir)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()synchronized close just so that if serialize is in place the close operation will block and will wait till serialize is done and will set the close flaglongdeserialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions)deserialize a data tree from the most recent snapshotvoiddeserialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, org.apache.jute.InputArchive ia)deserialize the datatree from an inputarchivejava.io.FilefindMostRecentSnapshot()find the most recent snapshot in the database.java.util.List<java.io.File>findNRecentSnapshots(int n)find the last n snapshots.voidserialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, java.io.File snapShot)serialize the datatree and session into the file snapshotprotected voidserialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, org.apache.jute.OutputArchive oa, FileHeader header)serialize the datatree and sessions
-
-
-
Field Detail
-
SNAP_MAGIC
public static final int SNAP_MAGIC
-
SNAPSHOT_FILE_PREFIX
public static final java.lang.String SNAPSHOT_FILE_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
deserialize
public long deserialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions) throws java.io.IOException
deserialize a data tree from the most recent snapshot- Specified by:
deserializein interfaceSnapShot- Parameters:
dt- the datatree to be deserialized intosessions- the sessions to be deserialized into- Returns:
- the zxid of the snapshot
- Throws:
java.io.IOException
-
deserialize
public void deserialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, org.apache.jute.InputArchive ia) throws java.io.IOException
deserialize the datatree from an inputarchive- Parameters:
dt- the datatree to be serialized intosessions- the sessions to be filled upia- the input archive to restore from- Throws:
java.io.IOException
-
findMostRecentSnapshot
public java.io.File findMostRecentSnapshot() throws java.io.IOExceptionfind the most recent snapshot in the database.- Specified by:
findMostRecentSnapshotin interfaceSnapShot- Returns:
- the file containing the most recent snapshot
- Throws:
java.io.IOException
-
findNRecentSnapshots
public java.util.List<java.io.File> findNRecentSnapshots(int n) throws java.io.IOExceptionfind the last n snapshots. this does not have any checks if the snapshot might be valid or not- Parameters:
the- number of most recent snapshots- Returns:
- the last n snapshots
- Throws:
java.io.IOException
-
serialize
protected void serialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, org.apache.jute.OutputArchive oa, FileHeader header) throws java.io.IOException
serialize the datatree and sessions- Parameters:
dt- the datatree to be serializedsessions- the sessions to be serializedoa- the output archive to serialize intoheader- the header of this snapshot- Throws:
java.io.IOException
-
serialize
public void serialize(DataTree dt, java.util.Map<java.lang.Long,java.lang.Integer> sessions, java.io.File snapShot) throws java.io.IOException
serialize the datatree and session into the file snapshot
-
-