• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BlockReportRequestProto类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto的典型用法代码示例。如果您正苦于以下问题:Java BlockReportRequestProto类的具体用法?Java BlockReportRequestProto怎么用?Java BlockReportRequestProto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlockReportRequestProto类属于org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos包,在下文中一共展示了BlockReportRequestProto类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public DatanodeCommand blockReport(DatanodeRegistration registration,
    String poolId, StorageBlockReport[] reports, BlockReportContext context)
      throws IOException {
  BlockReportRequestProto.Builder builder = BlockReportRequestProto
      .newBuilder().setRegistration(PBHelper.convert(registration))
      .setBlockPoolId(poolId);
  
  for (StorageBlockReport r : reports) {
    StorageBlockReportProto.Builder reportBuilder = StorageBlockReportProto
        .newBuilder().setStorage(PBHelper.convert(r.getStorage()));
    long[] blocks = r.getBlocks();
    for (int i = 0; i < blocks.length; i++) {
      reportBuilder.addBlocks(blocks[i]);
    }
    builder.addReports(reportBuilder.build());
  }
  builder.setContext(PBHelper.convert(context));
  BlockReportResponseProto resp;
  try {
    resp = rpcProxy.blockReport(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
  return resp.hasCmd() ? PBHelper.convert(resp.getCmd()) : null;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:27,代码来源:DatanodeProtocolClientSideTranslatorPB.java


示例2: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public DatanodeCommand blockReport(DatanodeRegistration registration,
    String poolId, StorageBlockReport[] reports) throws IOException {
  BlockReportRequestProto.Builder builder = BlockReportRequestProto
      .newBuilder().setRegistration(PBHelper.convert(registration))
      .setBlockPoolId(poolId);
  
  for (StorageBlockReport r : reports) {
    StorageBlockReportProto.Builder reportBuilder = StorageBlockReportProto
        .newBuilder().setStorage(PBHelper.convert(r.getStorage()));
    long[] blocks = r.getBlocks();
    for (int i = 0; i < blocks.length; i++) {
      reportBuilder.addBlocks(blocks[i]);
    }
    builder.addReports(reportBuilder.build());
  }
  BlockReportResponseProto resp;
  try {
    resp = rpcProxy.blockReport(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
  return resp.hasCmd() ? PBHelper.convert(resp.getCmd()) : null;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:25,代码来源:DatanodeProtocolClientSideTranslatorPB.java


示例3: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public DatanodeCommand blockReport(DatanodeRegistration registration,
    String poolId, StorageBlockReport[] reports) throws IOException {
  BlockReportRequestProto.Builder builder =
      BlockReportRequestProto.newBuilder()
          .setRegistration(PBHelper.convert(registration))
          .setBlockPoolId(poolId);

  for (StorageBlockReport r : reports) {
    StorageBlockReportProto.Builder reportBuilder =
        StorageBlockReportProto.newBuilder()
            .setStorage(PBHelper.convert(r.getStorage()))
            .setReport(PBHelper.convert(r.getReport()));
    builder.addReports(reportBuilder.build());
  }
  BlockReportResponseProto resp;
  try {
    resp = rpcProxy.blockReport(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
  return resp.hasCmd() ? PBHelper.convert(resp.getCmd()) : null;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:24,代码来源:DatanodeProtocolClientSideTranslatorPB.java


示例4: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public DatanodeCommand blockReport(DatanodeRegistration registration,
    String poolId, StorageBlockReport[] reports, BlockReportContext context)
      throws IOException {
  BlockReportRequestProto.Builder builder = BlockReportRequestProto
      .newBuilder().setRegistration(PBHelper.convert(registration))
      .setBlockPoolId(poolId);
  
  boolean useBlocksBuffer = registration.getNamespaceInfo()
      .isCapabilitySupported(Capability.STORAGE_BLOCK_REPORT_BUFFERS);

  for (StorageBlockReport r : reports) {
    StorageBlockReportProto.Builder reportBuilder = StorageBlockReportProto
        .newBuilder().setStorage(PBHelper.convert(r.getStorage()));
    BlockListAsLongs blocks = r.getBlocks();
    if (useBlocksBuffer) {
      reportBuilder.setNumberOfBlocks(blocks.getNumberOfBlocks());
      reportBuilder.addAllBlocksBuffers(blocks.getBlocksBuffers());
    } else {
      for (long value : blocks.getBlockListAsLongs()) {
        reportBuilder.addBlocks(value);
      }
    }
    builder.addReports(reportBuilder.build());
  }
  builder.setContext(PBHelper.convert(context));
  BlockReportResponseProto resp;
  try {
    resp = rpcProxy.blockReport(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
  return resp.hasCmd() ? PBHelper.convert(resp.getCmd()) : null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:DatanodeProtocolClientSideTranslatorPB.java


示例5: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public BlockReportResponseProto blockReport(RpcController controller,
    BlockReportRequestProto request) throws ServiceException {
  DatanodeCommand cmd = null;
  StorageBlockReport[] report = 
      new StorageBlockReport[request.getReportsCount()];
  
  int index = 0;
  for (StorageBlockReportProto s : request.getReportsList()) {
    final BlockListAsLongs blocks;
    if (s.hasNumberOfBlocks()) { // new style buffer based reports
      int num = (int)s.getNumberOfBlocks();
      Preconditions.checkState(s.getBlocksCount() == 0,
          "cannot send both blocks list and buffers");
      blocks = BlockListAsLongs.decodeBuffers(num, s.getBlocksBuffersList());
    } else {
      blocks = BlockListAsLongs.decodeLongs(s.getBlocksList());
    }
    report[index++] = new StorageBlockReport(PBHelper.convert(s.getStorage()),
        blocks);
  }
  try {
    cmd = impl.blockReport(PBHelper.convert(request.getRegistration()),
        request.getBlockPoolId(), report,
        request.hasContext() ?
            PBHelper.convert(request.getContext()) : null);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
  BlockReportResponseProto.Builder builder = 
      BlockReportResponseProto.newBuilder();
  if (cmd != null) {
    builder.setCmd(PBHelper.convert(cmd));
  }
  return builder.build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:DatanodeProtocolServerSideTranslatorPB.java


示例6: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public DatanodeCommand blockReport(DatanodeRegistration registration,
    String poolId, StorageBlockReport[] reports, BlockReportContext context)
      throws IOException {
  BlockReportRequestProto.Builder builder = BlockReportRequestProto
      .newBuilder().setRegistration(PBHelper.convert(registration))
      .setBlockPoolId(poolId);
  
  boolean useBlocksBuffer = registration.getNamespaceInfo()
      .isCapabilitySupported(Capability.STORAGE_BLOCK_REPORT_BUFFERS);

  for (StorageBlockReport r : reports) {
    StorageBlockReportProto.Builder reportBuilder = StorageBlockReportProto
        .newBuilder().setStorage(PBHelperClient.convert(r.getStorage()));
    BlockListAsLongs blocks = r.getBlocks();
    if (useBlocksBuffer) {
      reportBuilder.setNumberOfBlocks(blocks.getNumberOfBlocks());
      reportBuilder.addAllBlocksBuffers(blocks.getBlocksBuffers());
    } else {
      for (long value : blocks.getBlockListAsLongs()) {
        reportBuilder.addBlocks(value);
      }
    }
    builder.addReports(reportBuilder.build());
  }
  builder.setContext(PBHelper.convert(context));
  BlockReportResponseProto resp;
  try {
    resp = rpcProxy.blockReport(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
  return resp.hasCmd() ? PBHelper.convert(resp.getCmd()) : null;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:35,代码来源:DatanodeProtocolClientSideTranslatorPB.java


示例7: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public BlockReportResponseProto blockReport(RpcController controller,
    BlockReportRequestProto request) throws ServiceException {
  DatanodeCommand cmd = null;
  StorageBlockReport[] report = 
      new StorageBlockReport[request.getReportsCount()];
  
  int index = 0;
  for (StorageBlockReportProto s : request.getReportsList()) {
    final BlockListAsLongs blocks;
    if (s.hasNumberOfBlocks()) { // new style buffer based reports
      int num = (int)s.getNumberOfBlocks();
      Preconditions.checkState(s.getBlocksCount() == 0,
          "cannot send both blocks list and buffers");
      blocks = BlockListAsLongs.decodeBuffers(num, s.getBlocksBuffersList());
    } else {
      blocks = BlockListAsLongs.decodeLongs(s.getBlocksList());
    }
    report[index++] = new StorageBlockReport(PBHelperClient.convert(s.getStorage()),
        blocks);
  }
  try {
    cmd = impl.blockReport(PBHelper.convert(request.getRegistration()),
        request.getBlockPoolId(), report,
        request.hasContext() ?
            PBHelper.convert(request.getContext()) : null);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
  BlockReportResponseProto.Builder builder = 
      BlockReportResponseProto.newBuilder();
  if (cmd != null) {
    builder.setCmd(PBHelper.convert(cmd));
  }
  return builder.build();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:37,代码来源:DatanodeProtocolServerSideTranslatorPB.java


示例8: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public BlockReportResponseProto blockReport(RpcController controller,
    BlockReportRequestProto request) throws ServiceException {
  DatanodeCommand cmd = null;
  StorageBlockReport[] report = 
      new StorageBlockReport[request.getReportsCount()];
  
  int index = 0;
  for (StorageBlockReportProto s : request.getReportsList()) {
    List<Long> blockIds = s.getBlocksList();
    long[] blocks = new long[blockIds.size()];
    for (int i = 0; i < blockIds.size(); i++) {
      blocks[i] = blockIds.get(i);
    }
    report[index++] = new StorageBlockReport(PBHelper.convert(s.getStorage()),
        blocks);
  }
  try {
    cmd = impl.blockReport(PBHelper.convert(request.getRegistration()),
        request.getBlockPoolId(), report,
        request.hasContext() ?
            PBHelper.convert(request.getContext()) : null);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
  BlockReportResponseProto.Builder builder = 
      BlockReportResponseProto.newBuilder();
  if (cmd != null) {
    builder.setCmd(PBHelper.convert(cmd));
  }
  return builder.build();
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:33,代码来源:DatanodeProtocolServerSideTranslatorPB.java


示例9: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public BlockReportResponseProto blockReport(RpcController controller,
    BlockReportRequestProto request) throws ServiceException {
  DatanodeCommand cmd = null;
  StorageBlockReport[] report = 
      new StorageBlockReport[request.getReportsCount()];
  
  int index = 0;
  for (StorageBlockReportProto s : request.getReportsList()) {
    List<Long> blockIds = s.getBlocksList();
    long[] blocks = new long[blockIds.size()];
    for (int i = 0; i < blockIds.size(); i++) {
      blocks[i] = blockIds.get(i);
    }
    report[index++] = new StorageBlockReport(PBHelper.convert(s.getStorage()),
        blocks);
  }
  try {
    cmd = impl.blockReport(PBHelper.convert(request.getRegistration()),
        request.getBlockPoolId(), report);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
  BlockReportResponseProto.Builder builder = 
      BlockReportResponseProto.newBuilder();
  if (cmd != null) {
    builder.setCmd(PBHelper.convert(cmd));
  }
  return builder.build();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:31,代码来源:DatanodeProtocolServerSideTranslatorPB.java


示例10: blockReport

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Override
public BlockReportResponseProto blockReport(RpcController controller,
    BlockReportRequestProto request) throws ServiceException {
  DatanodeCommand cmd = null;
  StorageBlockReport[] storageBlockReports =
      new StorageBlockReport[request.getReportsCount()];
  
  int index = 0;
  for (StorageBlockReportProto s : request.getReportsList()) {
    DatanodeProtocolProtos.BlockReportProto report = s.getReport();
    storageBlockReports[index++] =
        new StorageBlockReport(PBHelper.convert(s.getStorage()),
            PBHelper.convert(report));
  }
  try {
    cmd = impl.blockReport(PBHelper.convert(request.getRegistration()),
        request.getBlockPoolId(), storageBlockReports);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
  BlockReportResponseProto.Builder builder =
      BlockReportResponseProto.newBuilder();
  if (cmd != null) {
    builder.setCmd(PBHelper.convert(cmd));
  }
  return builder.build();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:28,代码来源:DatanodeProtocolServerSideTranslatorPB.java


示例11: testDatanodeDetect

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Test
public void testDatanodeDetect() throws ServiceException, IOException {
  final AtomicReference<BlockReportRequestProto> request =
      new AtomicReference<>();

  // just capture the outgoing PB
  DatanodeProtocolPB mockProxy = mock(DatanodeProtocolPB.class);
  doAnswer(new Answer<BlockReportResponseProto>() {
    public BlockReportResponseProto answer(InvocationOnMock invocation) {
      Object[] args = invocation.getArguments();
      request.set((BlockReportRequestProto) args[1]);
      return BlockReportResponseProto.newBuilder().build();
    }
  }).when(mockProxy).blockReport(any(RpcController.class),
                                 any(BlockReportRequestProto.class));
  
  @SuppressWarnings("resource")
  DatanodeProtocolClientSideTranslatorPB nn =
      new DatanodeProtocolClientSideTranslatorPB(mockProxy);

  DatanodeRegistration reg = DFSTestUtil.getLocalDatanodeRegistration();
  NamespaceInfo nsInfo = new NamespaceInfo(1, "cluster", "bp", 1);
  reg.setNamespaceInfo(nsInfo);

  Replica r = new FinalizedReplica(new Block(1, 2, 3), null, null);
  BlockListAsLongs bbl = BlockListAsLongs.encode(Collections.singleton(r));
  DatanodeStorage storage = new DatanodeStorage("s1");
  StorageBlockReport[] sbr = { new StorageBlockReport(storage, bbl) };    

  // check DN sends new-style BR
  request.set(null);
  nsInfo.setCapabilities(Capability.STORAGE_BLOCK_REPORT_BUFFERS.getMask());
  nn.blockReport(reg, "pool", sbr,
      new BlockReportContext(1, 0, System.nanoTime()));
  BlockReportRequestProto proto = request.get();
  assertNotNull(proto);
  assertTrue(proto.getReports(0).getBlocksList().isEmpty());
  assertFalse(proto.getReports(0).getBlocksBuffersList().isEmpty());
  
  // back up to prior version and check DN sends old-style BR
  request.set(null);
  nsInfo.setCapabilities(Capability.UNKNOWN.getMask());
  nn.blockReport(reg, "pool", sbr,
      new BlockReportContext(1, 0, System.nanoTime()));
  proto = request.get();
  assertNotNull(proto);
  assertFalse(proto.getReports(0).getBlocksList().isEmpty());
  assertTrue(proto.getReports(0).getBlocksBuffersList().isEmpty());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:50,代码来源:TestBlockListAsLongs.java


示例12: testDatanodeDetect

import org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto; //导入依赖的package包/类
@Test
public void testDatanodeDetect() throws ServiceException, IOException {
  final AtomicReference<BlockReportRequestProto> request =
      new AtomicReference<>();

  // just capture the outgoing PB
  DatanodeProtocolPB mockProxy = mock(DatanodeProtocolPB.class);
  doAnswer(new Answer<BlockReportResponseProto>() {
    public BlockReportResponseProto answer(InvocationOnMock invocation) {
      Object[] args = invocation.getArguments();
      request.set((BlockReportRequestProto) args[1]);
      return BlockReportResponseProto.newBuilder().build();
    }
  }).when(mockProxy).blockReport(any(RpcController.class),
                                 any(BlockReportRequestProto.class));
  
  @SuppressWarnings("resource")
  DatanodeProtocolClientSideTranslatorPB nn =
      new DatanodeProtocolClientSideTranslatorPB(mockProxy);

  DatanodeRegistration reg = DFSTestUtil.getLocalDatanodeRegistration();
  NamespaceInfo nsInfo = new NamespaceInfo(1, "cluster", "bp", 1);
  reg.setNamespaceInfo(nsInfo);

  Replica r = new FinalizedReplica(new Block(1, 2, 3), null, null);
  BlockListAsLongs bbl = BlockListAsLongs.encode(Collections.singleton(r));
  DatanodeStorage storage = new DatanodeStorage("s1");
  StorageBlockReport[] sbr = { new StorageBlockReport(storage, bbl) };    

  // check DN sends new-style BR
  request.set(null);
  nsInfo.setCapabilities(Capability.STORAGE_BLOCK_REPORT_BUFFERS.getMask());
  nn.blockReport(reg, "pool", sbr,
      new BlockReportContext(1, 0, System.nanoTime(), 0L));
  BlockReportRequestProto proto = request.get();
  assertNotNull(proto);
  assertTrue(proto.getReports(0).getBlocksList().isEmpty());
  assertFalse(proto.getReports(0).getBlocksBuffersList().isEmpty());
  
  // back up to prior version and check DN sends old-style BR
  request.set(null);
  nsInfo.setCapabilities(Capability.UNKNOWN.getMask());
  nn.blockReport(reg, "pool", sbr,
      new BlockReportContext(1, 0, System.nanoTime(), 0L));
  proto = request.get();
  assertNotNull(proto);
  assertFalse(proto.getReports(0).getBlocksList().isEmpty());
  assertTrue(proto.getReports(0).getBlocksBuffersList().isEmpty());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:50,代码来源:TestBlockListAsLongs.java



注:本文中的org.apache.hadoop.hdfs.protocol.proto.DatanodeProtocolProtos.BlockReportRequestProto类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MD2类代码示例发布时间:2022-05-22
下一篇:
Java StoragePurger类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap