/** @return this node's path as its string representation */ @Override public String toString() { return getPath(this); }
/** * Get the path components of a node. * @param node a non-null node * @return the path of a node */ public static String[] getPathComponents(Node node) { return getPath(node).split(PATH_SEPARATOR_STR); }
@Override public int hashCode() { return getPath(this).hashCode(); }
/** convert a network tree to a string. */ @Override public String toString() { // print the number of racks StringBuilder tree = new StringBuilder(); tree.append("Number of racks: "); tree.append(numOfRacks); tree.append("\n"); // print the number of leaves int numOfLeaves = getNumOfLeaves(); tree.append("Expected number of leaves:"); tree.append(numOfLeaves); tree.append("\n"); // print nodes for(int i=0; i<numOfLeaves; i++) { tree.append(NodeBase.getPath(clusterMap.getLeaf(i, null))); tree.append("\n"); } return tree.toString(); }
/** Remove a node * Update node counter and rack counter if necessary * @param node node to be removed; can be null */ public void remove(Node node) { if (node==null) return; if( node instanceof InnerNode ) { throw new IllegalArgumentException( "Not allow to remove an inner node: "+NodeBase.getPath(node)); } LOG.info("Removing a node: "+NodeBase.getPath(node)); netlock.writeLock().lock(); try { if (clusterMap.remove(node)) { InnerNode rack = (InnerNode)getNode(node.getNetworkLocation()); if (rack == null) { numOfRacks--; } } LOG.debug("NetworkTopology became:\n{}", this); } finally { netlock.writeLock().unlock(); } }
if( node instanceof InnerNode ) { throw new IllegalArgumentException( "Not allow to add an inner node: "+NodeBase.getPath(node)); NodeBase.getPath(node), newDepth, this); throw new InvalidTopologyException("Failed to add " + NodeBase.getPath(node) + ": You cannot have a rack and a non-rack node at the same " + "level of the network topology."); LOG.info("Adding a new node: "+NodeBase.getPath(node)); if (rack == null) { incrementRacks();
+ chosenNode + " is already in excludedNodes " + excludedNodes); if (LOG.isDebugEnabled() && builder != null) { builder.append("\nNode ").append(NodeBase.getPath(chosenNode)) .append(" [");
sb.append(NodeBase.getPath(dnDesc)); } else { sb.append(new DatanodeInfoWithStorage(dnDesc, storage.getStorageID(),
/** @return this node's path as its string representation */ @Override public String toString() { return getPath(this); }
/** @return this node's path as its string representation */ @Override public String toString() { return getPath(this); }
/** @return this node's path as its string representation */ @Override public String toString() { return getPath(this); }
/** @return this node's path as its string representation */ @Override public String toString() { return getPath(this); }
/** Return this node's string representation */ public String toString() { return getPath(this); }
/** * This test checks that chooseRandom works for an excluded node. */ public void testChooseRandomExcludedNode() { String scope = "~" + NodeBase.getPath(dataNodes[0]); Map<Node, Integer> frequency = pickNodesAtRandom(100, scope); for (Node key : dataNodes) { // all nodes except the first should be more than zero assertTrue(frequency.get(key) > 0 || key == dataNodes[0]); } }
/** * This test checks that chooseRandom works for an excluded node. */ @Test public void testChooseRandomExcludedNode() { String scope = "~" + NodeBase.getPath(dataNodes[0]); Map<Node, Integer> frequency = pickNodesAtRandom(100, scope); for (Node key : dataNodes) { // all nodes except the first should be more than zero assertTrue(frequency.get(key) > 0 || key == dataNodes[0]); } }