Package org.apache.bookkeeper.util
Class StringUtils
- java.lang.Object
-
- org.apache.bookkeeper.util.StringUtils
-
public class StringUtils extends java.lang.ObjectProvided utilities for parsing network addresses, ledger-id from node paths etc.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFLAT_LEDGER_NODE_REGEXstatic java.lang.StringHIERARCHICAL_LEDGER_PARENT_NODE_REGEXstatic java.lang.StringLEDGER_NODE_PREFIXstatic java.lang.StringLEGACYHIERARCHICAL_LEDGER_PARENT_NODE_REGEXstatic java.lang.StringLONGHIERARCHICAL_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.StringgetHybridHierarchicalLedgerPath(long ledgerId)static java.lang.StringgetLongHierarchicalLedgerPath(long ledgerId)Get the long hierarchical ledger path according to the ledger id.static java.lang.StringgetShortHierarchicalLedgerPath(long ledgerId)Get the hierarchical ledger path according to the ledger id.static java.lang.StringgetZKStringId(long id)Formats ledger ID according to ZooKeeper rules.static java.lang.StringgetZKStringIdForLongHierarchical(long id)Formats ledger ID according to ZooKeeper rules.static java.lang.StringrequestToString(java.lang.Object request)Builds string representation of the request without extra (i.e.static longstringToHierarchicalLedgerId(java.lang.String hierarchicalLedgerPath)Parse the hierarchical ledger path to its ledger id.static longstringToHierarchicalLedgerId(java.lang.String... levelNodes)Get ledger id.static longstringToLongHierarchicalLedgerId(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.IOExceptionParse 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.IOExceptionParse 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.IOExceptionGet 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
-
-