Class NetworkTopologyImpl.InnerNode

  • All Implemented Interfaces:
    Node
    Enclosing class:
    NetworkTopologyImpl

    static class NetworkTopologyImpl.InnerNode
    extends NodeBase
    InnerNode represents a switch/router of a data center or rack. Different from a leaf node, it has non-null children.
    • Field Detail

      • children

        protected java.util.List<Node> children
    • Constructor Detail

      • InnerNode

        InnerNode​(java.lang.String path)
        Construct an InnerNode from a path-like string.
      • InnerNode

        InnerNode​(java.lang.String name,
                  java.lang.String location)
        Construct an InnerNode from its name and its network location.
      • InnerNode

        InnerNode​(java.lang.String name,
                  java.lang.String location,
                  NetworkTopologyImpl.InnerNode parent,
                  int level)
        Construct an InnerNode from its name, its network location, its parent, and its level.
    • Method Detail

      • getChildren

        java.util.List<Node> getChildren()
        Returns:
        its children
      • getNumOfChildren

        int getNumOfChildren()
        Returns:
        the number of children this node has
      • isRack

        boolean isRack()
        Judge if this node represents a rack.
        Returns:
        true if it has no child or its children are not InnerNodes
      • isAncestor

        boolean isAncestor​(Node n)
        Judge if this node is an ancestor of node n.
        Parameters:
        n - a node
        Returns:
        true if this node is an ancestor of n
      • isParent

        boolean isParent​(Node n)
        Judge if this node is the parent of node n.
        Parameters:
        n - a node
        Returns:
        true if this node is the parent of n
      • add

        boolean add​(Node n)
        Add node n to the subtree of this node.
        Parameters:
        n - node to be added
        Returns:
        true if the node is added; false otherwise
      • createParentNode

        protected NetworkTopologyImpl.InnerNode createParentNode​(java.lang.String parentName)
        Creates a parent node to be added to the list of children. Creates a node using the InnerNode four argument constructor specifying the name, location, parent, and level of this node.

        To be overridden in subclasses for specific InnerNode implementations, as alternative to overriding the full add(Node) method.

        Parameters:
        parentName - The name of the parent node
        Returns:
        A new inner node
        See Also:
        InnerNode(String, String, InnerNode, int)
      • remove

        boolean remove​(Node n)
        Remove node n from the subtree of this node.
        Parameters:
        n - node to be deleted
        Returns:
        true if the node is deleted; false otherwise
      • getLeaf

        Node getLeaf​(int leafIndex,
                     Node excludedNode)
        Get leafIndex leaf of this subtree if it is not in the excludedNode.
        Parameters:
        leafIndex - an indexed leaf of the node
        excludedNode - an excluded node (can be null)
        Returns:
      • isLeafParent

        protected boolean isLeafParent()
      • areChildrenLeaves

        protected boolean areChildrenLeaves()
        Determine if children a leaves, default implementation calls isRack().

        To be overridden in subclasses for specific InnerNode implementations, as alternative to overriding the full getLeaf(int, Node) method.

        Returns:
        true if children are leaves, false otherwise
      • getNumOfLeaves

        int getNumOfLeaves()
        Get number of leaves.