public class Util
extends java.lang.Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getFormatConversionPolicy(java.util.Properties props)
Extracts the value of the dbFormatConversion attribute.
|
static java.io.File |
getLogDir(java.util.Properties props)
Extracts transaction log directory property value from the container.
|
static java.io.File |
getSnapDir(java.util.Properties props)
Extracts snapshot directory property value from the container.
|
static long |
getZxidFromName(java.lang.String name,
java.lang.String prefix)
Extracts zxid from the file name.
|
static boolean |
isValidSnapshot(java.io.File f)
Verifies that the file is a valid snapshot.
|
static java.net.URI |
makeFileLoggerURL(java.io.File dataDir,
java.io.File dataLogDir)
Given two directory files the method returns a well-formed
logfile provider URI.
|
static java.net.URI |
makeFileLoggerURL(java.io.File dataDir,
java.io.File dataLogDir,
java.lang.String convPolicy) |
static java.lang.String |
makeLogName(long zxid)
Creates a valid transaction log file name.
|
static java.lang.String |
makeSnapshotName(long zxid)
Creates a snapshot file name.
|
static java.lang.String |
makeURIString(java.lang.String dataDir,
java.lang.String dataLogDir,
java.lang.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(java.io.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 java.util.List<java.io.File> |
sortDataDir(java.io.File[] files,
java.lang.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 java.lang.String makeURIString(java.lang.String dataDir, java.lang.String dataLogDir, java.lang.String convPolicy)
public static java.net.URI makeFileLoggerURL(java.io.File dataDir, java.io.File dataLogDir)
dataDir
- snapshot directorydataLogDir
- transaction log directorypublic static java.net.URI makeFileLoggerURL(java.io.File dataDir, java.io.File dataLogDir, java.lang.String convPolicy)
public static java.lang.String makeLogName(long zxid)
zxid
- used as a file name suffix (extention)public static java.lang.String makeSnapshotName(long zxid)
zxid
- used as a suffixpublic static java.io.File getSnapDir(java.util.Properties props)
props
- properties containerpublic static java.io.File getLogDir(java.util.Properties props)
props
- properties containerpublic static java.lang.String getFormatConversionPolicy(java.util.Properties props)
props
- properties containerpublic static long getZxidFromName(java.lang.String name, java.lang.String prefix)
makeLogName
or makeSnapshotName
.name
- the file name to parseprefix
- the file name prefix (snapshot or log)public static boolean isValidSnapshot(java.io.File f) throws java.io.IOException
f
- file to verifyjava.io.IOException
public static long padLogFile(java.io.FileOutputStream f, long currentSize, long preAllocSize) throws java.io.IOException
f
- output stream to padcurrentSize
- application keeps track of the cuurent file sizepreAllocSize
- how many bytes to padjava.io.IOException
public static byte[] readTxnBytes(org.apache.jute.InputArchive ia) throws java.io.IOException
ia
- archive to read fromjava.io.IOException
public static byte[] marshallTxnEntry(TxnHeader hdr, org.apache.jute.Record txn) throws java.io.IOException
hdr
- transaction headertxn
- transaction datajava.io.IOException
public static void writeTxnBytes(org.apache.jute.OutputArchive oa, byte[] bytes) throws java.io.IOException
oa
- output archivebytes
- serialized trasnaction recordjava.io.IOException
public static java.util.List<java.io.File> sortDataDir(java.io.File[] files, java.lang.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