You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "MaWenJin (JIRA)" <ji...@apache.org> on 2013/01/29 10:23:12 UTC

[jira] [Created] (HDFS-4450) Duplicate data node on the name node after formatting data node

MaWenJin created HDFS-4450:
------------------------------

             Summary: Duplicate data node on the name node after formatting data node
                 Key: HDFS-4450
                 URL: https://issues.apache.org/jira/browse/HDFS-4450
             Project: Hadoop HDFS
          Issue Type: Bug
          Components: namenode
    Affects Versions: 2.0.2-alpha
            Reporter: MaWenJin


Duplicate data node on the name node after formatting data node。
When we registered data node,use nodeReg.getXferPort() to find DatanodeDescriptor.
{code}
 DatanodeDescriptor nodeN = host2DatanodeMap.getDatanodeByXferAddr(
        nodeReg.getIpAddr(), nodeReg.getXferPort());
{code}

but add data node use node.getIpAddr().
{code}
    /** add node to the map 
   * return true if the node is added; false otherwise.
   */
  boolean add(DatanodeDescriptor node) {
    hostmapLock.writeLock().lock();
    try {
      if (node==null || contains(node)) {
        return false;
      }
      
      String ipAddr = node.getIpAddr();
      DatanodeDescriptor[] nodes = map.get(ipAddr);
      DatanodeDescriptor[] newNodes;
      if (nodes==null) {
        newNodes = new DatanodeDescriptor[1];
        newNodes[0]=node;
      } else { // rare case: more than one datanode on the host
        newNodes = new DatanodeDescriptor[nodes.length+1];
        System.arraycopy(nodes, 0, newNodes, 0, nodes.length);
        newNodes[nodes.length] = node;
      }
      map.put(ipAddr, newNodes);
      return true;
    } finally {
      hostmapLock.writeLock().unlock();
    }
  }
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira