Package org.apache.hadoop.net

Examples of org.apache.hadoop.net.Node


      HashMap<Node, Node> excludedNodes) {
    int countOfExcludedNodes = 0;
    String nodeGroupScope = localMachine.getNetworkLocation();
    List<Node> leafNodes = clusterMap.getLeaves(nodeGroupScope);
    for (Node leafNode : leafNodes) {
      Node node = excludedNodes.put(leafNode, leafNode);
      if (node == null) {
        // not a existing node in excludedNodes
        countOfExcludedNodes++;
      }
    }
View Full Code Here


    if (localMachine == null)
      return chooseRandom(NodeBase.ROOT, excludedNodes, blocksize,
          maxNodesPerRack, results, avoidStaleNodes);
     
    // otherwise try local machine first
    Node oldNode = excludedNodes.put(localMachine, localMachine);
    if (oldNode == null) { // was not in the excluded list
      if (isGoodTarget(localMachine, blocksize, maxNodesPerRack, false,
          results, avoidStaleNodes)) {
        results.add(localMachine);
        // add localMachine and related nodes to excludedNode
View Full Code Here

    * the same failure domain of localMachine
    * @return number of new excluded nodes
    */
  protected int addToExcludedNodes(DatanodeDescriptor localMachine,
      HashMap<Node, Node> excludedNodes) {
    Node node = excludedNodes.put(localMachine, localMachine);
    return node == null?1:0;
  }
View Full Code Here

      clusterMap.countNumOfAvailableNodes(nodes, excludedNodes.keySet());
    while(numOfAvailableNodes > 0) {
      DatanodeDescriptor chosenNode =
        (DatanodeDescriptor)(clusterMap.chooseRandom(nodes));

      Node oldNode = excludedNodes.put(chosenNode, chosenNode);
      if (oldNode == null) { // chosendNode was not in the excluded list
        numOfAvailableNodes--;
        if (isGoodTarget(chosenNode, blocksize, maxNodesPerRack, results,
            avoidStaleNodes)) {
          results.add(chosenNode);
View Full Code Here

    int numOfAvailableNodes =
      clusterMap.countNumOfAvailableNodes(nodes, excludedNodes.keySet());
    while(numOfReplicas > 0 && numOfAvailableNodes > 0) {
      DatanodeDescriptor chosenNode =
        (DatanodeDescriptor)(clusterMap.chooseRandom(nodes));
      Node oldNode = excludedNodes.put(chosenNode, chosenNode);
      if (oldNode == null) {
        numOfAvailableNodes--;

        if (isGoodTarget(chosenNode, blocksize, maxNodesPerRack, results,
            avoidStaleNodes)) {
View Full Code Here

    // check if the target rack has chosen too many nodes
    String rackname = node.getNetworkLocation();
    int counter=1;
    for(Iterator<DatanodeDescriptor> iter = results.iterator();
        iter.hasNext();) {
      Node result = iter.next();
      if (rackname.equals(result.getNetworkLocation())) {
        counter++;
      }
    }
    if (counter>maxTargetPerLoc) {
      logr.debug("Node "+NodeBase.getPath(node)+
View Full Code Here

 
  @Test
  public void testLocality() throws Exception {
    NetworkTopology nt = new NetworkTopology();

    Node r1n1 = new NodeBase("/default/rack1/node1");
    nt.add(r1n1);
    Node r1n2 = new NodeBase("/default/rack1/node2");
    nt.add(r1n2);

    Node r2n3 = new NodeBase("/default/rack2/node3");
    nt.add(r2n3);

    LOG.debug("r1n1 parent: " + r1n1.getParent() + "\n" +
              "r1n2 parent: " + r1n2.getParent() + "\n" +
              "r2n3 parent: " + r2n3.getParent());

    // Same host
    assertEquals(0, JobInProgress.getMatchingLevelForNodes(r1n1, r1n1, 3));
    // Same rack
    assertEquals(1, JobInProgress.getMatchingLevelForNodes(r1n1, r1n2, 3));
View Full Code Here

      InetAddress iaddr = InetAddress.getByName("host1");
      MyResolver.resolvedHost1 = iaddr.getHostAddress();
    } catch (UnknownHostException e) {
      // Ignore if not found
    }
    Node node = RackResolver.resolve("host1");
    Assert.assertEquals("/rack1", node.getNetworkLocation());
    node = RackResolver.resolve("host1");
    Assert.assertEquals("/rack1", node.getNetworkLocation());
    node = RackResolver.resolve(invalidHost);
    Assert.assertEquals(NetworkTopology.DEFAULT_RACK, node.getNetworkLocation());
  }
View Full Code Here

    if (localMachine == null)
      return chooseRandom(NodeBase.ROOT, excludedNodes,
          blocksize, maxNodesPerRack, results, avoidStaleNodes);

    // otherwise try local machine first
    Node oldNode = excludedNodes.put(localMachine, localMachine);
    if (oldNode == null) { // was not in the excluded list
      if (isGoodTarget(localMachine, blocksize,
          maxNodesPerRack, false, results, avoidStaleNodes)) {
        results.add(localMachine);
        // Nodes under same nodegroup should be excluded.
View Full Code Here

      HashMap<Node, Node> excludedNodes) {
    int countOfExcludedNodes = 0;
    String nodeGroupScope = localMachine.getNetworkLocation();
    List<Node> leafNodes = clusterMap.getLeaves(nodeGroupScope);
    for (Node leafNode : leafNodes) {
      Node node = excludedNodes.put(leafNode, leafNode);
      if (node == null) {
        // not a existing node in excludedNodes
        countOfExcludedNodes++;
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.net.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.