public NetworkTopology() { this.rootNode = new NetworkNode(DEFAULT_ROOT_NODE_NAME, null, this); }
public int getDepth() { if (this.isRootNode()) { return 1; } return (1 + this.parentNode.getDepth()); }
public int getDepth() { return this.rootNode.getHeight(); }
/** * Determines the distance to the given network node. The distance is determined as the number of internal network * nodes that must be traversed in order to send a packet from one node to the other plus one. * * @param networkNode * the node to determine the distance for * @return the distance to the given network node or <code>Integer.MAX_VALUE</code> if the given node is not part of * this node's network topology */ public int getDistance(final NetworkNode networkNode) { int steps = 0; NetworkNode tmp = this; while (tmp != null) { final int distance = tmp.isPredecessorOrSelfOf(networkNode); if (distance >= 0) { return (steps + distance); } tmp = tmp.getParentNode(); ++steps; } return Integer.MAX_VALUE; }
public void remove() { if (!isLeafNode()) { return; } if (this.parentNode != null) { this.parentNode.removeChild(this); } if (this.networkTopology != null) { this.networkTopology.removeNode(this); } }
@Override public void read(final DataInput in) throws IOException { this.name = StringRecord.readString(in); // We need to read the name before we can add the node to the topology's node map if (this.networkTopology != null) { this.networkTopology.addNode(this); } final int numberOfChildNodes = in.readInt(); for (int i = 0; i < numberOfChildNodes; i++) { final NetworkNode networkNode = new NetworkNode(this, this.networkTopology); networkNode.read(in); this.childNodes.add(networkNode); } }
if (currentStubNode.getParentNode() != null) { parentNode = currentStubNode.getParentNode(); currentStubNode.remove(); + parentNode.getName()); final ClusterInstance host = new ClusterInstance(instanceConnectionInfo, instanceType, parentNode, this.networkTopology, hardwareDescription);
private void refillStack() { while (true) { final TraversalEntry traversalEntry = this.traversalStack.peek(); final NetworkNode networkNode = traversalEntry.getNetworkNode(); if (networkNode.isLeafNode()) { break; } final NetworkNode childNode = networkNode.getChildNode(traversalEntry.getChildrenVisited()); this.traversalStack.add(new TraversalEntry(childNode)); } }
void removeNode(NetworkNode networkNode) { this.nodeMap.remove(networkNode.getName()); }
protected NetworkNode(final String name, final NetworkNode parentNode, final NetworkTopology networkTopology) { this.name = name; this.parentNode = parentNode; this.networkTopology = networkTopology; if (this.parentNode != null) { this.parentNode.addChild(this); } if (this.networkTopology != null) { this.networkTopology.addNode(this); } }
public int getDistance(final String nodeName) { final NetworkNode networkNode = this.networkTopology.getNodeByName(nodeName); if (networkNode == null) { return Integer.MAX_VALUE; } if (this.equals(networkNode)) { return 0; } return getDistance(networkNode); }
@Override public NetworkNode next() { final TraversalEntry traversalEntry = this.traversalStack.pop(); final NetworkNode networkNode = traversalEntry.networkNode; if (!this.traversalStack.isEmpty()) { final TraversalEntry parentTraversalEntry = this.traversalStack.peek(); parentTraversalEntry.increaseChildrenVisited(); if (parentTraversalEntry.getChildrenVisited() < parentTraversalEntry.getNetworkNode() .getNumberOfChildNodes()) { refillStack(); } } return networkNode; }
/** * Checks whether this node is a predecessor or the identity (the node itself) of the given network node in the * network topology tree. * * @param networkNode * a potential child network node * @return If this node node is a predecessor of given node in the network topology tree, the return value * indicates the distance between both nodes. If the given node equals this node, the * return value is <code>0</code>. Otherwise the return value is <code>-1</code>. */ private int isPredecessorOrSelfOf(final NetworkNode networkNode) { NetworkNode tmp = networkNode; int steps = 0; while (tmp != null) { if (this.equals(tmp)) { return steps; } tmp = tmp.getParentNode(); ++steps; } return -1; }
@Override public void read(final DataInput in) throws IOException { this.name = StringRecord.readString(in); // We need to read the name before we can add the node to the topology's node map if (this.networkTopology != null) { this.networkTopology.addNode(this); } final int numberOfChildNodes = in.readInt(); for (int i = 0; i < numberOfChildNodes; i++) { final NetworkNode networkNode = new NetworkNode(this, this.networkTopology); networkNode.read(in); this.childNodes.add(networkNode); } }
if (currentStubNode.getParentNode() != null) { parentNode = currentStubNode.getParentNode(); currentStubNode.remove(); + parentNode.getName()); final ClusterInstance host = new ClusterInstance(instanceConnectionInfo, instanceType, parentNode, this.networkTopology, hardwareDescription);
public void remove() { if (!isLeafNode()) { return; } if (this.parentNode != null) { this.parentNode.removeChild(this); } if (this.networkTopology != null) { this.networkTopology.removeNode(this); } }
private void refillStack() { while (true) { final TraversalEntry traversalEntry = this.traversalStack.peek(); final NetworkNode networkNode = traversalEntry.getNetworkNode(); if (networkNode.isLeafNode()) { break; } final NetworkNode childNode = networkNode.getChildNode(traversalEntry.getChildrenVisited()); this.traversalStack.add(new TraversalEntry(childNode)); } }
/** * Determines the distance to the given network node. The distance is determined as the number of internal network * nodes that must be traversed in order to send a packet from one node to the other plus one. * * @param networkNode * the node to determine the distance for * @return the distance to the given network node or <code>Integer.MAX_VALUE</code> if the given node is not part of * this node's network topology */ public int getDistance(final NetworkNode networkNode) { int steps = 0; NetworkNode tmp = this; while (tmp != null) { final int distance = tmp.isPredecessorOrSelfOf(networkNode); if (distance >= 0) { return (steps + distance); } tmp = tmp.getParentNode(); ++steps; } return Integer.MAX_VALUE; }
void addNode(final NetworkNode networkNode) { this.nodeMap.put(networkNode.getName(), networkNode); }
protected NetworkNode(final String name, final NetworkNode parentNode, final NetworkTopology networkTopology) { this.name = name; this.parentNode = parentNode; this.networkTopology = networkTopology; if (this.parentNode != null) { this.parentNode.addChild(this); } if (this.networkTopology != null) { this.networkTopology.addNode(this); } }