|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.zookeeper.server.persistence.Util
public class Util
A collection of utility methods for dealing with file name parsing, low level I/O file operations and marshalling/unmarshalling.
Constructor Summary | |
---|---|
Util()
|
Method Summary | |
---|---|
static String |
getFormatConversionPolicy(Properties props)
Extracts the value of the dbFormatConversion attribute. |
static File |
getLogDir(Properties props)
Extracts transaction log directory property value from the container. |
static File |
getSnapDir(Properties props)
Extracts snapshot directory property value from the container. |
static long |
getZxidFromName(String name,
String prefix)
Extracts zxid from the file name. |
static boolean |
isValidSnapshot(File f)
Verifies that the file is a valid snapshot. |
static URI |
makeFileLoggerURL(File dataDir,
File dataLogDir)
Given two directory files the method returns a well-formed logfile provider URI. |
static URI |
makeFileLoggerURL(File dataDir,
File dataLogDir,
String convPolicy)
|
static String |
makeLogName(long zxid)
Creates a valid transaction log file name. |
static String |
makeSnapshotName(long zxid)
Creates a snapshot file name. |
static String |
makeURIString(String dataDir,
String dataLogDir,
String convPolicy)
|
static byte[] |
marshallTxnEntry(org.apache.zookeeper.txn.TxnHeader hdr,
Record txn)
Serializes transaction header and transaction data into a byte buffer. |
static long |
padLogFile(FileOutputStream f,
long currentSize,
long preAllocSize)
Grows the file to the specified number of bytes. |
static byte[] |
readTxnBytes(InputArchive ia)
Reads a transaction entry from the input archive. |
static List<File> |
sortDataDir(File[] files,
String prefix,
boolean ascending)
Sort the list of files. |
static void |
writeTxnBytes(OutputArchive oa,
byte[] bytes)
Write the serialized transaction record to the output archive. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Util()
Method Detail |
---|
public static String makeURIString(String dataDir, String dataLogDir, String convPolicy)
public static URI makeFileLoggerURL(File dataDir, File dataLogDir)
dataDir
- snapshot directorydataLogDir
- transaction log directory
public static URI makeFileLoggerURL(File dataDir, File dataLogDir, String convPolicy)
public static String makeLogName(long zxid)
zxid
- used as a file name suffix (extention)
public static String makeSnapshotName(long zxid)
zxid
- used as a suffix
public static File getSnapDir(Properties props)
props
- properties container
public static File getLogDir(Properties props)
props
- properties container
public static String getFormatConversionPolicy(Properties props)
props
- properties container
public static long getZxidFromName(String name, String prefix)
makeLogName
or makeSnapshotName
.
name
- the file name to parseprefix
- the file name prefix (snapshot or log)
public static boolean isValidSnapshot(File f) throws IOException
f
- file to verify
IOException
public static long padLogFile(FileOutputStream f, long currentSize, long preAllocSize) throws IOException
f
- output stream to padcurrentSize
- application keeps track of the cuurent file sizepreAllocSize
- how many bytes to pad
IOException
public static byte[] readTxnBytes(InputArchive ia) throws IOException
ia
- archive to read from
IOException
public static byte[] marshallTxnEntry(org.apache.zookeeper.txn.TxnHeader hdr, Record txn) throws IOException
hdr
- transaction headertxn
- transaction data
IOException
public static void writeTxnBytes(OutputArchive oa, byte[] bytes) throws IOException
oa
- output archivebytes
- serialized trasnaction record
IOException
public static List<File> sortDataDir(File[] files, String prefix, boolean ascending)
files
- array of filesprefix
- files not matching this prefix are assumed to have a
version = -1)ascending
- true sorted in ascending order, false results in
descending order
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |