Class FileSnap
- java.lang.Object
- 
- org.apache.zookeeper.server.persistence.FileSnap
 
- 
- 
Field SummaryFields Modifier and Type Field Description static intSNAP_MAGICstatic StringSNAPSHOT_FILE_PREFIX
 - 
Method SummaryAll 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, Map<Long,Integer> sessions)deserialize a data tree from the most recent snapshotvoiddeserialize(DataTree dt, Map<Long,Integer> sessions, InputArchive ia)deserialize the datatree from an inputarchiveFilefindMostRecentSnapshot()find the most recent snapshot in the database.List<File>findNRecentSnapshots(int n)find the last n snapshots.protected List<File>findNValidSnapshots(int n)find the last (maybe) valid n snapshots.SnapshotInfogetLastSnapshotInfo()get information of the last saved/restored snapshotvoidserialize(DataTree dt, Map<Long,Integer> sessions, File snapShot, boolean fsync)serialize the datatree and session into the file snapshotprotected voidserialize(DataTree dt, Map<Long,Integer> sessions, OutputArchive oa, FileHeader header)serialize the datatree and sessions
 
- 
- 
- 
Field Detail- 
SNAP_MAGICpublic static final int SNAP_MAGIC 
 - 
SNAPSHOT_FILE_PREFIXpublic static final String SNAPSHOT_FILE_PREFIX - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
FileSnappublic FileSnap(File snapDir) 
 
- 
 - 
Method Detail- 
getLastSnapshotInfopublic SnapshotInfo getLastSnapshotInfo() get information of the last saved/restored snapshot- Specified by:
- getLastSnapshotInfoin interface- SnapShot
- Returns:
- info of last snapshot
 
 - 
deserializepublic long deserialize(DataTree dt, Map<Long,Integer> sessions) throws IOException deserialize a data tree from the most recent snapshot- Specified by:
- deserializein interface- SnapShot
- Parameters:
- dt- the datatree to be deserialized into
- sessions- the sessions to be deserialized into
- Returns:
- the zxid of the snapshot
- Throws:
- IOException
 
 - 
deserializepublic void deserialize(DataTree dt, Map<Long,Integer> sessions, InputArchive ia) throws IOException deserialize the datatree from an inputarchive- Parameters:
- dt- the datatree to be serialized into
- sessions- the sessions to be filled up
- ia- the input archive to restore from
- Throws:
- IOException
 
 - 
findMostRecentSnapshotpublic File findMostRecentSnapshot() find the most recent snapshot in the database.- Specified by:
- findMostRecentSnapshotin interface- SnapShot
- Returns:
- the file containing the most recent snapshot
 
 - 
findNValidSnapshotsprotected List<File> findNValidSnapshots(int n) find the last (maybe) valid n snapshots. this does some minor checks on the validity of the snapshots. It just checks for / at the end of the snapshot. This does not mean that the snapshot is truly valid but is valid with a high probability. also, the most recent will be first on the list.- Parameters:
- n- the number of most recent snapshots
- Returns:
- the last n snapshots (the number might be less than n in case enough snapshots are not available).
 
 - 
findNRecentSnapshotspublic List<File> findNRecentSnapshots(int n) throws IOException find the last n snapshots. this does not have any checks if the snapshot might be valid or not- Parameters:
- n- the number of most recent snapshots
- Returns:
- the last n snapshots
- Throws:
- IOException
 
 - 
serializeprotected void serialize(DataTree dt, Map<Long,Integer> sessions, OutputArchive oa, FileHeader header) throws IOException serialize the datatree and sessions- Parameters:
- dt- the datatree to be serialized
- sessions- the sessions to be serialized
- oa- the output archive to serialize into
- header- the header of this snapshot
- Throws:
- IOException
 
 - 
serializepublic void serialize(DataTree dt, Map<Long,Integer> sessions, File snapShot, boolean fsync) throws IOException serialize the datatree and session into the file snapshot- Specified by:
- serializein interface- SnapShot
- Parameters:
- dt- the datatree to be serialized
- sessions- the sessions to be serialized
- snapShot- the file to store snapshot into
- fsync- sync the file immediately after write
- Throws:
- IOException
 
 - 
closepublic void close() throws IOExceptionsynchronized 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 flag- Specified by:
- closein interface- SnapShot
- Throws:
- IOException
 
 
- 
 
-