Examples of NumberReplicas


Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

          addToInvalidates(block);
          continue;
        }
        // calculate current replication
        short expectedReplication = fileINode.getReplication();
        NumberReplicas num = countNodes(block);
        int numCurrentReplica = num.liveReplicas();
        // add to under-replicated queue if need to be
        if (isNeededReplication(block, expectedReplication, numCurrentReplica)) {
          if (neededReplications.add(block, numCurrentReplica, num
              .decommissionedReplicas(), expectedReplication)) {
            nrUnderReplicated++;
          }
        }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

        } else {
          live++;
        }
      }
    }
    return new NumberReplicas(live, count, corrupt, excess);
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

    while(it.hasNext()) {
      final Block block = it.next();
      INode fileINode = blocksMap.getINode(block);

      if (fileINode != null) {
        NumberReplicas num = countNodes(block);
        int curReplicas = num.liveReplicas();
        int curExpectedReplicas = getReplication(block);
        if (isNeededReplication(block, curExpectedReplicas, curReplicas)) {
          if (curExpectedReplicas > curReplicas) {
            //Log info about one block for this node which needs replication
            if (!status) {
              status = true;
              logBlockReplicationInfo(block, srcNode, num);
            }
            underReplicatedBlocks++;
            if ((curReplicas == 0) && (num.decommissionedReplicas() > 0)) {
              decommissionOnlyReplicas++;
            }
            if (fileINode.isUnderConstruction()) {
              underReplicatedInOpenFiles++;
            }
          }
          if (!neededReplications.contains(block) &&
            pendingReplications.getNumReplicas(block) == 0) {
            //
            // These blocks have been reported from the datanode
            // after the startDecommission method has been executed. These
            // blocks were in flight when the decommissioning was started.
            //
            neededReplications.add(block,
                                   curReplicas,
                                   num.decommissionedReplicas(),
                                   curExpectedReplicas);
          }
        }
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

  /* updates a block in under replication queue */
  void updateNeededReplications(Block block, int curReplicasDelta,
      int expectedReplicasDelta) {
    namesystem.writeLock();
    try {
      NumberReplicas repl = countNodes(block);
      int curExpectedReplicas = getReplication(block);
      if (isNeededReplication(block, curExpectedReplicas, repl.liveReplicas())) {
        neededReplications.update(block, repl.liveReplicas(), repl
            .decommissionedReplicas(), curExpectedReplicas, curReplicasDelta,
            expectedReplicasDelta);
      } else {
        int oldReplicas = repl.liveReplicas()-curReplicasDelta;
        int oldExpectedReplicas = curExpectedReplicas-expectedReplicasDelta;
        neededReplications.remove(block, oldReplicas, repl.decommissionedReplicas(),
                                  oldExpectedReplicas);
      }
    } finally {
      namesystem.writeUnlock();
    }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

    }
  }

  void checkReplication(Block block, int numExpectedReplicas) {
    // filter out containingNodes that are marked for decommission.
    NumberReplicas number = countNodes(block);
    if (isNeededReplication(block, numExpectedReplicas, number.liveReplicas())) {
      neededReplications.add(block,
                             number.liveReplicas(),
                             number.decommissionedReplicas,
                             numExpectedReplicas);
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

      LOG.info("Start a new node");
      cluster.restartDataNode(dnprop);
      cluster.waitActive(false);
      // The block should be replicated
      LOG.info("wait for the block to replicate");
      NumberReplicas num;
      long startTime = System.currentTimeMillis();
      do {
       namesystem.readLock();
       try {
         num = namesystem.countNodes(block);
         namesystem.metaSave("TestLostDataNodeAfterDeleteExcessReplica.meta");
       } finally {
         namesystem.readUnlock();
       }
       Thread.sleep(1000);
       LOG.info("live: " + num.liveReplicas());
      } while (num.liveReplicas() != 3 &&
          System.currentTimeMillis() - startTime < 30000);
      assertEquals("Live Replicas doesn't reach 3", num.liveReplicas(), 3);
    } finally {
      cluster.shutdown();
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

      LOG.info("Start a new node");
      cluster.restartDataNode(dnprop);
      cluster.waitActive(false);
      // The block should be replicated
      LOG.info("wait for the block to replicate");
      NumberReplicas num;
      long startTime = System.currentTimeMillis();
      do {
       namesystem.readLock();
       try {
         num = namesystem.countNodes(block);
         namesystem.metaSave("TestDecommissionDataNodeAfterDeleteExcessReplica.meta");
       } finally {
         namesystem.readUnlock();
       }
       Thread.sleep(1000);
       LOG.info("live: " + num.liveReplicas() + "Decom: " + num.decommissionedReplicas());
      } while (num.liveReplicas() != 3 &&
          System.currentTimeMillis() - startTime < 30000);
      assertEquals("Live Replicas doesn't reach 3", num.liveReplicas(), 3);
    } finally {
      cluster.shutdown();
    }
  }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

      // bring up the datanode
      cluster.restartDataNode(dnprop);

      // Wait for block report
      LOG.info("wait for its block report to come in");
      NumberReplicas num;
      long startTime = System.currentTimeMillis();
      do {
       namesystem.readLock();
       try {
         num = namesystem.countNodes(block);
       } finally {
         namesystem.readUnlock();
       }
       Thread.sleep(1000);
       LOG.info("live: " + num.liveReplicas()
           + "Decom: " + num.decommissionedReplicas());
      } while (num.decommissionedReplicas() != 1 &&
          System.currentTimeMillis() - startTime < 30000);
      assertEquals("Decommissioning Replicas doesn't reach 1",
          1, num.decommissionedReplicas());
      assertEquals(1, namesystem.getNonCorruptUnderReplicatedBlocks());
      assertEquals(0, namesystem.getMissingBlocksCount());
    } finally {
      cluster.shutdown();
    }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

  private void waitForExcessReplicasToChange(
      FSNamesystem namesystem,
      Block block,
      int newReplicas) throws Exception
    {
      NumberReplicas num;
      long startChecking = System.currentTimeMillis();
      do {
        namesystem.readLock();
        try {
          num = namesystem.countNodes(block);
        } finally {
          namesystem.readUnlock();
        }
        Thread.sleep(100);
        if (System.currentTimeMillis() - startChecking > 30000) {
          fail("Timed out waiting for excess replicas to change");
        }

      } while (num.excessReplicas() != newReplicas);
    }
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.FSNamesystem.NumberReplicas

        namesystem.heartbeatCheck();
      }
     
      LOG.info("Waiting for live replicas to hit repl factor");
      // The block should be replicated
      NumberReplicas num;
      do {
       namesystem.readLock();
       try {
         num = namesystem.countNodes(block);
       } finally {
         namesystem.readUnlock();
       }
      } while (num.liveReplicas() != REPLICATION_FACTOR);
     
      LOG.info("Restarting first DN");
      // restart the first datanode
      cluster.restartDataNode(dnprop);
      cluster.waitActive(false);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.