當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockReport類代碼示例

本文整理匯總了Java中org.apache.hadoop.hdfs.server.protocol.BlockReport的典型用法代碼示例。如果您正苦於以下問題:Java BlockReport類的具體用法?Java BlockReport怎麽用?Java BlockReport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BlockReport類屬於org.apache.hadoop.hdfs.server.protocol包,在下文中一共展示了BlockReport類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: blockReportNew

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
public DatanodeCommand blockReportNew(DatanodeRegistration nodeReg, BlockReport rep) throws IOException {
  if (runInfo.shutdown || !runInfo.isRunning) {
    return null;
  }
  if (ignoreDatanodes()) {
    LOG.info("Standby fell behind. Telling " + nodeReg.toString() +
              " to back off");
    // Do not process block reports yet as the ingest thread is catching up
    return AvatarDatanodeCommand.BACKOFF;
  }
  
  if (currentAvatar == Avatar.STANDBY) {
    Collection<Block> failed = super.blockReportWithRetries(nodeReg, rep);

    // standby should send only DNA_RETRY
    BlockCommand bCmd = new BlockCommand(DatanodeProtocols.DNA_RETRY,
        failed.toArray(new Block[failed.size()]));
    return bCmd;
  } else {
    // only the primary can send DNA_FINALIZE
    return super.blockReport(nodeReg, rep);
  }
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:24,代碼來源:AvatarNode.java

示例2: calculateMismatchedHashes

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
private HashMatchingResult calculateMismatchedHashes(DatanodeDescriptor dn,
    BlockReport report) throws IOException {
  List<HashBucket> allMachineHashes = HashBuckets.getInstance()
      .getBucketsForDatanode(dn);
  List<Integer> matchedBuckets = new ArrayList<>();
  List<Integer> mismatchedBuckets = new ArrayList<>();
  
  for (int i = 0; i < report.getBuckets().length; i++){
    boolean matched = false;
    for (HashBucket bucket : allMachineHashes){
      if (bucket.getBucketId() == i && bucket.getHash() == report
          .getHashes()[i]){
        matched = true;
        break;
      }
    }
    if (matched){
      matchedBuckets.add(i);
    } else {
      mismatchedBuckets.add(i);
    }
  }
  
  return new HashMatchingResult(matchedBuckets, mismatchedBuckets);
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:26,代碼來源:BlockManager.java

示例3: register

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
void register() throws IOException {
  // get versions from the namenode
  nsInfo = nameNodeProto.versionRequest();
  dnRegistration = new DatanodeRegistration(
      new DatanodeID(DNS.getDefaultIP("default"),
          DNS.getDefaultHost("default", "default"), "", getNodePort(dnIdx),
          DFSConfigKeys.DFS_DATANODE_HTTP_DEFAULT_PORT,
          DFSConfigKeys.DFS_DATANODE_IPC_DEFAULT_PORT),
      new DataStorage(nsInfo, ""), new ExportedBlockKeys(),
      VersionInfo.getVersion());
  DataNode.setNewStorageID(dnRegistration);
  // register datanode
  dnRegistration = nameNodeProto.registerDatanode(dnRegistration);
  //first block reports
  storage = new DatanodeStorage(dnRegistration.getStorageID());
  final StorageBlockReport[] reports = {new StorageBlockReport(storage,
      BlockReport.builder(NUM_BUCKETS).build())};
  nameNodeProto.blockReport(dnRegistration,
      nameNode.getNamesystem().getBlockPoolId(), reports);
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:21,代碼來源:NNThroughputBenchmark.java

示例4: testSafeModeIBRAfterIncremental

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
@Test
public void testSafeModeIBRAfterIncremental() throws Exception {
  DatanodeDescriptor node = spy(nodes.get(0));
  node.setStorageID("dummy-storage");
  node.isAlive = true;

  DatanodeRegistration nodeReg =
      new DatanodeRegistration(node, null, null, "");

  // pretend to be in safemode
  doReturn(true).when(fsn).isInStartupSafeMode();

  // register new node
  bm.getDatanodeManager().registerDatanode(nodeReg);
  bm.getDatanodeManager().addDatanode(node); // swap in spy    
  assertEquals(node, bm.getDatanodeManager().getDatanode(node));
  assertTrue(node.isFirstBlockReport());
  // send block report while pretending to already have blocks
  reset(node);
  doReturn(1).when(node).numBlocks();
  bm.processReport(node, "pool", BlockReport.builder(numBuckets).build());
  verify(node).receivedBlockReport();
  assertFalse(node.isFirstBlockReport());
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:25,代碼來源:TestBlockManager.java

示例5: blockReport_06

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
/**
 * Test creates a file and closes it.
 * The second datanode is started in the cluster.
 * As soon as the replication process is completed test runs
 * Block report and checks that no underreplicated blocks are left
 *
 * @throws IOException
 *     in case of an error
 */
@Test
public void blockReport_06() throws Exception {
  final String METHOD_NAME = GenericTestUtils.getMethodName();
  Path filePath = new Path("/" + METHOD_NAME + ".dat");
  final int DN_N1 = DN_N0 + 1;

  ArrayList<Block> blocks = writeFile(METHOD_NAME, FILE_SIZE, filePath);
  startDNandWait(filePath, true);

  // all blocks belong to the same file, hence same BP
  DataNode dn = cluster.getDataNodes().get(DN_N1);
  String poolId = cluster.getNamesystem().getBlockPoolId();
  DatanodeRegistration dnR = dn.getDNRegistrationForBP(poolId);
  StorageBlockReport[] report =
      {new StorageBlockReport(new DatanodeStorage(dnR.getStorageID()),
          BlockReport.builder(NUM_BUCKETS).addAllAsFinalized(blocks).build())};
  cluster.getNameNodeRpc().blockReport(dnR, poolId, report);
  printStats();
  Thread.sleep(10000); //HOP: wait for the replication monitor to catch up
  assertEquals("Wrong number of PendingReplication Blocks", 0,
      cluster.getNamesystem().getUnderReplicatedBlocks());
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:32,代碼來源:TestBlockReport.java

示例6: blockReportNew

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
public DatanodeCommand blockReportNew(DatanodeRegistration nodeReg, BlockReport rep) throws IOException {
  if (runInfo.shutdown || !runInfo.isRunning) {
    return null;
  }
  if (ignoreDatanodes()) {
    LOG.info("Standby fell behind. Telling " + nodeReg.toString() +
              " to back off");
    // Do not process block reports yet as the ingest thread is catching up
    return AvatarDatanodeCommand.BACKOFF;
  }

  if (currentAvatar == Avatar.STANDBY) {
    Collection<Block> failed = super.blockReportWithRetries(nodeReg, rep);

    BlockCommand bCmd = new BlockCommand(DatanodeProtocols.DNA_RETRY,
        failed.toArray(new Block[failed.size()]));
    return bCmd;
  } else {
    return super.blockReport(nodeReg, rep);
  }
}
 
開發者ID:iVCE,項目名稱:RDFS,代碼行數:22,代碼來源:AvatarNode.java

示例7: blocksBeingWrittenReport

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
/**
* add new replica blocks to the Inode to target mapping
* also add the Inode file to DataNodeDesc
*/
public void blocksBeingWrittenReport(DatanodeRegistration nodeReg,
    BlockReport blocks) throws IOException {
  verifyRequest(nodeReg);
  long[] blocksAsLong = blocks.getBlockReportInLongs();
  BlockListAsLongs blist = new BlockListAsLongs(blocksAsLong);
  boolean processed = namesystem.processBlocksBeingWrittenReport(nodeReg, blist);

  String message = "*BLOCK* NameNode.blocksBeingWrittenReport: "
      +"from "+nodeReg.getName()+" "+blist.getNumberOfBlocks() +" blocks";
  if (!processed) {
    message += " was discarded.";
  }
  stateChangeLog.info(message);
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:19,代碼來源:NameNode.java

示例8: blockReportWithRetries

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
protected Collection<Block> blockReportWithRetries(
    DatanodeRegistration nodeReg, BlockReport blocks) throws IOException {
  verifyRequest(nodeReg);
  myMetrics.numBlockReport.inc();
  BlockListAsLongs blist =
    new BlockListAsLongs(blocks.getBlockReportInLongs());
  stateChangeLog.debug("*BLOCK* NameNode.blockReport: " + "from "
      + nodeReg.getName() + " " + blist.getNumberOfBlocks() + " blocks");

  return namesystem.processReport(nodeReg, blist);
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:12,代碼來源:NameNode.java

示例9: sendBlocksBeingWrittenReport

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
/**
 * Sends a 'Blocks Being Written' report to the given node.
 *
 * @param node the node to send the report to
 * @throws IOException
 */
public void sendBlocksBeingWrittenReport(DatanodeProtocol node,
    int namespaceId, DatanodeRegistration nsRegistration) throws IOException {
  Block[] blocks = data.getBlocksBeingWrittenReport(namespaceId);
  if (blocks != null && blocks.length != 0) {
    long[] blocksAsLong =
      BlockListAsLongs.convertToArrayLongs(blocks);
    BlockReport bbwReport = new BlockReport(blocksAsLong);
    node.blocksBeingWrittenReport(nsRegistration, bbwReport);
  }
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:17,代碼來源:DataNode.java

示例10: blockReport

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
@Override // DatanodeProtocol
public DatanodeCommand blockReport(DatanodeRegistration nodeReg,
    String poolId, StorageBlockReport[] reports) throws IOException {
  verifyRequest(nodeReg);
  
  BlockReport blist = reports[0].getReport(); // Assume no federation '0'
  if (blockStateChangeLog.isDebugEnabled()) {
    blockStateChangeLog.debug(
        "*BLOCK* NameNode.blockReport: " + "from " + nodeReg + " " +
            blist.getNumBlocks() + " blocks");
  }

  namesystem.getBlockManager().processReport(nodeReg, poolId, blist);
  return new FinalizeCommand(poolId);
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:16,代碼來源:NameNodeRpcServer.java

示例11: applyHash

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
public void applyHash(int storageId, HdfsServerConstants.ReplicaState state,
    Block block ) throws TransactionContextException, StorageException {
  int bucketId = getBucketForBlock(block);
  HashBucket bucket = getBucket(storageId, bucketId);
 
  
  long newHash = bucket.getHash() + BlockReport.hash(block, state);
  LOG.debug("Applying block:" + blockToString
      (block) + "sid: " + storageId + "state: " + state.name() + ", hash: "
      + BlockReport.hash(block, state));
  
  bucket.setHash(newHash);
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:14,代碼來源:HashBuckets.java

示例12: undoHash

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
public void undoHash(int storageId, HdfsServerConstants.ReplicaState
    state, Block block) throws TransactionContextException, StorageException {
  int bucketId = getBucketForBlock(block);
  HashBucket bucket = getBucket(storageId, bucketId);
  long newHash = bucket.getHash() - BlockReport.hash(block, state);
  LOG.debug("Undo block:" + blockToString
      (block) + "sid: " + storageId + "state: " + state.name() + ", hash: " +
      BlockReport.hash(block,state));
  
  bucket.setHash(newHash);
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:12,代碼來源:HashBuckets.java

示例13: getBlockReport

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
/**
 * Generates a block report from the in-memory block map.
 */
@Override // FsDatasetSpi
public BlockReport getBlockReport(String bpid) {
  int size = volumeMap.size(bpid);
  BlockReport.Builder builder = BlockReport.builder(NUM_BUCKETS);
  if (size == 0) {
    return builder.build();
  }
  
  synchronized (this) {
    for (ReplicaInfo b : volumeMap.replicas(bpid)) {
      switch (b.getState()) {
        case FINALIZED:
        case RBW:
        case RWR:
          builder.add(b);
          break;
        case RUR:
          ReplicaUnderRecovery rur = (ReplicaUnderRecovery) b;
          builder.add(rur.getOriginalReplica());
          break;
        case TEMPORARY:
          break;
        default:
          assert false : "Illegal ReplicaInfo state.";
      }
    }
    return builder.build();
  }
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:33,代碼來源:FsDatasetImpl.java

示例14: convert

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
public static DatanodeProtocolProtos.BlockReportProto convert(BlockReport report) {
 
  List<DatanodeProtocolProtos.BlockReportBucketProto> bucketProtos = new
      ArrayList<>();
  for (BlockReportBucket bucket : report.getBuckets()){

    DatanodeProtocolProtos.BlockReportBucketProto.Builder bucketBuilder =
        DatanodeProtocolProtos.BlockReportBucketProto.newBuilder();
    for (BlockReportBlock block : bucket.getBlocks()){
      bucketBuilder.addBlocks(
          DatanodeProtocolProtos.BlockReportBlockProto.newBuilder()
              .setBlockId(block.getBlockId())
              .setGenerationStamp(block.getGenerationStamp())
              .setLength(block.getLength())
              .setState(convert(block.getState())));
    }
    bucketProtos.add(bucketBuilder.build());
  }

  List<Long> hashes = new ArrayList<>();
  for (long hash : report.getHashes()){
    hashes.add(hash);
  }
  
  return DatanodeProtocolProtos.BlockReportProto.newBuilder()
      .addAllBuckets(bucketProtos)
      .addAllHashes(hashes)
      .build();
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:30,代碼來源:PBHelper.java

示例15: getAllBlockReports

import org.apache.hadoop.hdfs.server.protocol.BlockReport; //導入依賴的package包/類
/**
 * @return block reports from all data nodes
 * BlockListAsLongs is indexed in the same order as the list of datanodes
 * returned by getDataNodes()
 */
public Iterable<BlockReportBlock>[] getAllBlockReports(String bpid) {
  int numDataNodes = dataNodes.size();
  Iterable<BlockReportBlock>[] result = new BlockReport[numDataNodes];
  for (int i = 0; i < numDataNodes; ++i) {
    result[i] = getBlockReport(bpid, i);
  }
  return result;
}
 
開發者ID:hopshadoop,項目名稱:hops,代碼行數:14,代碼來源:MiniDFSCluster.java


注:本文中的org.apache.hadoop.hdfs.server.protocol.BlockReport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。