Package org.apache.bookkeeper.net
Class NodeBase
java.lang.Object
org.apache.bookkeeper.net.NodeBase
- All Implemented Interfaces:
Node
- Direct Known Subclasses:
BookieNode,NetworkTopologyImpl.InnerNode
A base class that implements interface Node.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNodeBase()Default constructor.Construct a node from its path.Construct a node from its name and its location.Construct a node from its name and its location. -
Method Summary
Modifier and TypeMethodDescriptionintgetLevel()getName()getNetworkLocation(int distanceFromLeaves) static StringGet the path of a node.static intlocationToDepth(String location) static StringNormalize a path by stripping off any trailingPATH_SEPARATOR.voidsetLevel(int level) Set this node's level in the tree.voidsetNetworkLocation(String location) Set this node's network location.voidSet this node's parent.toString()
-
Field Details
-
PATH_SEPARATOR
public static final char PATH_SEPARATORPath separator '/'.- See Also:
-
PATH_SEPARATOR_STR
Path separator as a string "/".- See Also:
-
ROOT
String representation of root "".- See Also:
-
name
-
location
-
level
protected int level -
parent
-
-
Constructor Details
-
NodeBase
public NodeBase()Default constructor. -
NodeBase
Construct a node from its path.- Parameters:
path- a concatenation of this node's location, the path separator, and its name
-
NodeBase
Construct a node from its name and its location.- Parameters:
name- this node's name (can be null, must not containPATH_SEPARATOR)location- this node's location
-
NodeBase
Construct a node from its name and its location.- Parameters:
name- this node's name (can be null, must not containPATH_SEPARATOR)location- this node's locationparent- this node's parent nodelevel- this node's level in the tree
-
-
Method Details
-
getName
-
getNetworkLocation
- Specified by:
getNetworkLocationin interfaceNode- Returns:
- this node's network location
-
setNetworkLocation
Set this node's network location.- Specified by:
setNetworkLocationin interfaceNode- Parameters:
location- the location
-
getPath
Get the path of a node.- Parameters:
node- a non-null node- Returns:
- the path of a node
-
toString
-
normalize
Normalize a path by stripping off any trailingPATH_SEPARATOR.- Parameters:
path- path to normalize.- Returns:
- the normalised path
If pathis null or empty
ROOTis returned - Throws:
IllegalArgumentException- if the first character of a non empty path is notPATH_SEPARATOR
-
getParent
-
setParent
Set this node's parent. -
getLevel
public int getLevel() -
setLevel
public void setLevel(int level) Set this node's level in the tree. -
locationToDepth
-
getNetworkLocation
- Specified by:
getNetworkLocationin interfaceNode- Returns:
- the string representation of this node's network location at the specified level in the hierarchy
-