/** * Get the path of a node * @param node a non-null node * @return the path of a node */ public static String getPath(Node node) { return node.getNetworkLocation() + PATH_SEPARATOR_STR + node.getName(); }
@Override public boolean remove(Node n) { if (!isAncestor(n)) { throw new IllegalArgumentException(n.getName() + ", which is located at " + n.getNetworkLocation() + ", is not a descendant of " + getPath(this)); if (childrenMap.containsKey(n.getName())) { for (int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(n.getName())) { children.remove(i); childrenMap.remove(n.getName()); numOfLeaves--; n.setParent(null); if (parentNode.getNumOfChildren() == 0) { for(int i=0; i < children.size(); i++) { if (children.get(i).getName().equals(parentName)) { children.remove(i); childrenMap.remove(parentName);
@Override public boolean add(Node n) { if (!isAncestor(n)) { throw new IllegalArgumentException(n.getName() + ", which is located at " + n.getNetworkLocation() + ", is not a descendant of " + getPath(this)); Node prev = childrenMap.put(n.getName(), n); if (prev != null) { for(int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(n.getName())) { children.set(i, n); return false;
if (isLeaf) { // excluded node is a leaf node if (excludedNode != null && childrenMap.containsKey(excludedNode.getName())) { int excludedIndex = children.indexOf(excludedNode); if (excludedIndex != -1 && leafIndex >= 0) {
@Override public boolean remove(Node n) { LOG.debug("removing node {}", n.getName()); if (!isAncestor(n)) { throw new IllegalArgumentException(n.getName() + ", which is located at " + n.getNetworkLocation() + ", is not a descendant of " + getPath(this)); if (isParent(n)) { if (childrenMap.containsKey(n.getName())) { for (int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(n.getName())) { children.remove(i); childrenMap.remove(n.getName()); childrenStorageInfo.remove(dnDescriptor.getName()); for (StorageType st : dnDescriptor.getStorageTypes()) { if (children.get(i).getName().equals(parentName)) { children.remove(i); childrenMap.remove(parentName);
@Override public boolean add(Node n) { LOG.debug("adding node {}", n.getName()); if (!isAncestor(n)) { throw new IllegalArgumentException(n.getName() + ", which is located at " + n.getNetworkLocation() + ", is not a descendant of " + getPath(this)); Node prev = childrenMap.put(n.getName(), n); if (prev != null) { for(int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(n.getName())) { children.set(i, n); updateExistingDatanode(dnDescriptor);
+ "/" + excludedNode.getName(); DatanodeDescriptor dn = (DatanodeDescriptor)getNode(nodeLocation); availableCount -= dn.hasStorageType(type)? 1 : 0;
@Override public void addNode(List<NMContainerStatus> containerStatuses, RMNode rmNode) { if (LOG.isDebugEnabled()) { LOG.debug("Node added event from: " + rmNode.getNode().getName()); } // Ignoring this currently : at least one NODE_UPDATE heartbeat is // required to ensure node eligibility. }
/** * Get the path of a node * @param node a non-null node * @return the path of a node */ public static String getPath(Node node) { return node.getNetworkLocation() + PATH_SEPARATOR_STR + node.getName(); }
/** * Get the path of a node * @param node a non-null node * @return the path of a node */ public static String getPath(Node node) { return node.getNetworkLocation() + PATH_SEPARATOR_STR + node.getName(); }
/** * Get the path of a node * @param node a non-null node * @return the path of a node */ public static String getPath(Node node) { return node.getNetworkLocation() + PATH_SEPARATOR_STR + node.getName(); }
/** * Get the path of a node * @param node a non-null node * @return the path of a node */ public static String getPath(Node node) { return node.getNetworkLocation() + PATH_SEPARATOR_STR + node.getName(); }
/** Return this node's path */ public static String getPath(Node node) { return node.getNetworkLocation()+PATH_SEPARATOR_STR+node.getName(); }
/** Return this node's path */ public static String getPath(Node node) { return node.getNetworkLocation()+PATH_SEPARATOR_STR+node.getName(); }
/** Given a node's string representation, return a reference to the node */ private Node getLoc(String loc) { if (loc == null || loc.length() == 0) return this; String[] path = loc.split(PATH_SEPARATOR_STR, 2); Node childnode = null; for(int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(path[0])) { childnode = children.get(i); } } if (childnode == null) return null; // non-existing node if (path.length == 1) return childnode; if (childnode instanceof InnerNode) { return ((InnerNode)childnode).getLoc(path[1]); } else { return null; } }
/** Given a node's string representation, return a reference to the node * @param loc string location of the form /rack/node * @return null if the node is not found or the childnode is there but * not an instance of {@link InnerNode} */ private Node getLoc(String loc) { if (loc == null || loc.length() == 0) return this; String[] path = loc.split(PATH_SEPARATOR_STR, 2); Node childnode = null; for(int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(path[0])) { childnode = children.get(i); } } if (childnode == null) return null; // non-existing node if (path.length == 1) return childnode; if (childnode instanceof InnerNode) { return ((InnerNode)childnode).getLoc(path[1]); } else { return null; } }
/** Given a node's string representation, return a reference to the node * @param loc string location of the form /rack/node * @return null if the node is not found or the childnode is there but * not an instance of {@link InnerNode} */ private Node getLoc(String loc) { if (loc == null || loc.length() == 0) return this; String[] path = loc.split(PATH_SEPARATOR_STR, 2); Node childnode = null; for(int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(path[0])) { childnode = children.get(i); } } if (childnode == null) return null; // non-existing node if (path.length == 1) return childnode; if (childnode instanceof InnerNode) { return ((InnerNode)childnode).getLoc(path[1]); } else { return null; } }
/** Given a node's string representation, return a reference to the node */ private Node getLoc(String loc) { if (loc == null || loc.length() == 0) return this; String[] path = StringUtils.split(loc, PATH_SEPARATOR, 2); Node childnode = null; for(int i=0; i<children.size(); i++) { if (children.get(i).getName().equals(path[0])) { childnode = children.get(i); } } if (childnode == null) return null; // non-existing node if (path.length == 1) return childnode; if (childnode instanceof InnerNode) { return ((InnerNode)childnode).getLoc(path[1]); } else { return null; } }
@Override public void removeNode(RMNode removedRMNode) { LOG.debug("Node delete event for: " + removedRMNode.getNode().getName()); ReentrantReadWriteLock.WriteLock writeLock = clusterNodesLock.writeLock(); writeLock.lock(); ClusterNode node; try { node = this.clusterNodes.remove(removedRMNode.getNodeID()); } finally { writeLock.unlock(); } if (LOG.isDebugEnabled()) { if (node != null) { LOG.debug("Delete ClusterNode: " + removedRMNode.getNodeID()); } else { LOG.debug("Node not in list!"); } } }