Package org.apache.bookkeeper.util
Class StringUtils
- java.lang.Object
-
- org.apache.bookkeeper.util.StringUtils
-
public class StringUtils extends java.lang.Object
Provided utilities for parsing network addresses, ledger-id from node paths etc.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FLAT_LEDGER_NODE_REGEX
static java.lang.String
HIERARCHICAL_LEDGER_PARENT_NODE_REGEX
static java.lang.String
LEDGER_NODE_PREFIX
static java.lang.String
LEGACYHIERARCHICAL_LEDGER_PARENT_NODE_REGEX
static java.lang.String
LONGHIERARCHICAL_LEDGER_PARENT_NODE_REGEX
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getHybridHierarchicalLedgerPath(long ledgerId)
static java.lang.String
getLongHierarchicalLedgerPath(long ledgerId)
Get the long hierarchical ledger path according to the ledger id.static java.lang.String
getShortHierarchicalLedgerPath(long ledgerId)
Get the hierarchical ledger path according to the ledger id.static java.lang.String
getZKStringId(long id)
Formats ledger ID according to ZooKeeper rules.static java.lang.String
getZKStringIdForLongHierarchical(long id)
Formats ledger ID according to ZooKeeper rules.static java.lang.String
requestToString(java.lang.Object request)
Builds string representation of the request without extra (i.e.static long
stringToHierarchicalLedgerId(java.lang.String hierarchicalLedgerPath)
Parse the hierarchical ledger path to its ledger id.static long
stringToHierarchicalLedgerId(java.lang.String... levelNodes)
Get ledger id.static long
stringToLongHierarchicalLedgerId(java.lang.String longHierarchicalLedgerPath)
Parse the long hierarchical ledger path to its ledger id.
-
-
-
Field Detail
-
LEDGER_NODE_PREFIX
public static final java.lang.String LEDGER_NODE_PREFIX
- See Also:
- Constant Field Values
-
FLAT_LEDGER_NODE_REGEX
public static final java.lang.String FLAT_LEDGER_NODE_REGEX
- See Also:
- Constant Field Values
-
LEGACYHIERARCHICAL_LEDGER_PARENT_NODE_REGEX
public static final java.lang.String LEGACYHIERARCHICAL_LEDGER_PARENT_NODE_REGEX
- See Also:
- Constant Field Values
-
LONGHIERARCHICAL_LEDGER_PARENT_NODE_REGEX
public static final java.lang.String LONGHIERARCHICAL_LEDGER_PARENT_NODE_REGEX
- See Also:
- Constant Field Values
-
HIERARCHICAL_LEDGER_PARENT_NODE_REGEX
public static final java.lang.String HIERARCHICAL_LEDGER_PARENT_NODE_REGEX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getZKStringId
public static java.lang.String getZKStringId(long id)
Formats ledger ID according to ZooKeeper rules.- Parameters:
id
- znode id
-
getZKStringIdForLongHierarchical
public static java.lang.String getZKStringIdForLongHierarchical(long id)
Formats ledger ID according to ZooKeeper rules.- Parameters:
id
- znode id
-
getShortHierarchicalLedgerPath
public static java.lang.String getShortHierarchicalLedgerPath(long ledgerId)
Get the hierarchical ledger path according to the ledger id.- Parameters:
ledgerId
- ledger id- Returns:
- the hierarchical path
-
getLongHierarchicalLedgerPath
public static java.lang.String getLongHierarchicalLedgerPath(long ledgerId)
Get the long hierarchical ledger path according to the ledger id.- Parameters:
ledgerId
- ledger id- Returns:
- the long hierarchical path
-
getHybridHierarchicalLedgerPath
public static java.lang.String getHybridHierarchicalLedgerPath(long ledgerId)
-
stringToHierarchicalLedgerId
public static long stringToHierarchicalLedgerId(java.lang.String hierarchicalLedgerPath) throws java.io.IOException
Parse the hierarchical ledger path to its ledger id.- Parameters:
hierarchicalLedgerPath
-- Returns:
- the ledger id
- Throws:
java.io.IOException
-
stringToLongHierarchicalLedgerId
public static long stringToLongHierarchicalLedgerId(java.lang.String longHierarchicalLedgerPath) throws java.io.IOException
Parse the long hierarchical ledger path to its ledger id.- Parameters:
longHierarchicalLedgerPaths
-- Returns:
- the ledger id
- Throws:
java.io.IOException
-
stringToHierarchicalLedgerId
public static long stringToHierarchicalLedgerId(java.lang.String... levelNodes) throws java.io.IOException
Get ledger id.- Parameters:
levelNodes
- level of the ledger path- Returns:
- ledger id
- Throws:
java.io.IOException
-
requestToString
public static java.lang.String requestToString(java.lang.Object request)
Builds string representation of the request without extra (i.e. binary) data- Parameters:
request
-- Returns:
- string representation of request
-
-