public class Util extends Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
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(TxnHeader hdr,
org.apache.jute.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(org.apache.jute.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(org.apache.jute.OutputArchive oa,
byte[] bytes)
Write the serialized transaction record to the output archive.
|
public static String makeURIString(String dataDir, String dataLogDir, String convPolicy)
public static URI makeFileLoggerURL(File dataDir, File dataLogDir)
dataDir
- snapshot directorydataLogDir
- transaction log directorypublic 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 suffixpublic static File getSnapDir(Properties props)
props
- properties containerpublic static File getLogDir(Properties props)
props
- properties containerpublic static String getFormatConversionPolicy(Properties props)
props
- properties containerpublic 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 verifyIOException
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 padIOException
public static byte[] readTxnBytes(org.apache.jute.InputArchive ia) throws IOException
ia
- archive to read fromIOException
public static byte[] marshallTxnEntry(TxnHeader hdr, org.apache.jute.Record txn) throws IOException
hdr
- transaction headertxn
- transaction dataIOException
public static void writeTxnBytes(org.apache.jute.OutputArchive oa, byte[] bytes) throws IOException
oa
- output archivebytes
- serialized trasnaction recordIOException
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 orderCopyright © 2017 The Apache Software Foundation