Java 类org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.DatanodeInfoProto 实例源码

项目:hadoop    文件:PBHelper.java   
public static DatanodeInfoProto convert(DatanodeInfo info) {
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (info.getNetworkLocation() != null) {
    builder.setLocation(info.getNetworkLocation());
  }
  builder
      .setId(PBHelper.convert((DatanodeID)info))
      .setCapacity(info.getCapacity())
      .setDfsUsed(info.getDfsUsed())
      .setRemaining(info.getRemaining())
      .setBlockPoolUsed(info.getBlockPoolUsed())
      .setCacheCapacity(info.getCacheCapacity())
      .setCacheUsed(info.getCacheUsed())
      .setLastUpdate(info.getLastUpdate())
      .setLastUpdateMonotonic(info.getLastUpdateMonotonic())
      .setXceiverCount(info.getXceiverCount())
      .setAdminState(PBHelper.convert(info.getAdminState()))
      .build();
  return builder.build();
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<String> existingStorageIDsList = req.getExistingStorageUuidsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(req.getSrc(),
        req.getFileId(), PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        existingStorageIDsList.toArray(
            new String[existingStorageIDsList.size()]),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
        req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:aliyun-oss-hadoop-fs    文件:PBHelperClient.java   
public static DatanodeInfoProto convert(DatanodeInfo info) {
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (info.getNetworkLocation() != null) {
    builder.setLocation(info.getNetworkLocation());
  }
  if (info.getUpgradeDomain() != null) {
    builder.setUpgradeDomain(info.getUpgradeDomain());
  }
  builder
      .setId(convert((DatanodeID) info))
      .setCapacity(info.getCapacity())
      .setDfsUsed(info.getDfsUsed())
      .setRemaining(info.getRemaining())
      .setBlockPoolUsed(info.getBlockPoolUsed())
      .setCacheCapacity(info.getCacheCapacity())
      .setCacheUsed(info.getCacheUsed())
      .setLastUpdate(info.getLastUpdate())
      .setLastUpdateMonotonic(info.getLastUpdateMonotonic())
      .setXceiverCount(info.getXceiverCount())
      .setAdminState(convert(info.getAdminState()))
      .build();
  return builder.build();
}
项目:aliyun-oss-hadoop-fs    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelperClient.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelperClient.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelperClient.convertLocatedBlock(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:aliyun-oss-hadoop-fs    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<String> existingStorageIDsList = req.getExistingStorageUuidsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(req.getSrc(),
        req.getFileId(), PBHelperClient.convert(req.getBlk()),
        PBHelperClient.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        existingStorageIDsList.toArray(
            new String[existingStorageIDsList.size()]),
        PBHelperClient.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])),
        req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
    PBHelperClient.convertLocatedBlock(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:big-c    文件:PBHelper.java   
public static DatanodeInfoProto convert(DatanodeInfo info) {
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (info.getNetworkLocation() != null) {
    builder.setLocation(info.getNetworkLocation());
  }
  builder
      .setId(PBHelper.convert((DatanodeID)info))
      .setCapacity(info.getCapacity())
      .setDfsUsed(info.getDfsUsed())
      .setRemaining(info.getRemaining())
      .setBlockPoolUsed(info.getBlockPoolUsed())
      .setCacheCapacity(info.getCacheCapacity())
      .setCacheUsed(info.getCacheUsed())
      .setLastUpdate(info.getLastUpdate())
      .setLastUpdateMonotonic(info.getLastUpdateMonotonic())
      .setXceiverCount(info.getXceiverCount())
      .setAdminState(PBHelper.convert(info.getAdminState()))
      .build();
  return builder.build();
}
项目:big-c    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:big-c    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<String> existingStorageIDsList = req.getExistingStorageUuidsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(req.getSrc(),
        req.getFileId(), PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        existingStorageIDsList.toArray(
            new String[existingStorageIDsList.size()]),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
        req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:PBHelper.java   
public static DatanodeInfoProto convert(DatanodeInfo info) {
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (info.getNetworkLocation() != null) {
    builder.setLocation(info.getNetworkLocation());
  }
  builder
      .setId(PBHelper.convert((DatanodeID)info))
      .setCapacity(info.getCapacity())
      .setDfsUsed(info.getDfsUsed())
      .setRemaining(info.getRemaining())
      .setBlockPoolUsed(info.getBlockPoolUsed())
      .setCacheCapacity(info.getCacheCapacity())
      .setCacheUsed(info.getCacheUsed())
      .setLastUpdate(info.getLastUpdate())
      .setXceiverCount(info.getXceiverCount())
      .setAdminState(PBHelper.convert(info.getAdminState()))
      .build();
  return builder.build();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<String> existingStorageIDsList = req.getExistingStorageUuidsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(req.getSrc(),
        req.getFileId(), PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        existingStorageIDsList.toArray(
            new String[existingStorageIDsList.size()]),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
        req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-plus    文件:PBHelper.java   
static public DatanodeInfoProto convertDatanodeInfo(DatanodeInfo di) {
  if (di == null) return null;
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (di.getNetworkLocation() != null) {
    builder.setLocation(di.getNetworkLocation());
  }

  return builder.
   setId(PBHelper.convert((DatanodeID) di)).
   setCapacity(di.getCapacity()).
   setDfsUsed(di.getDfsUsed()).
   setRemaining(di.getRemaining()).
   setBlockPoolUsed(di.getBlockPoolUsed()).
   setLastUpdate(di.getLastUpdate()).
   setXceiverCount(di.getXceiverCount()).
   setAdminState(PBHelper.convert(di.getAdminState())).
   build();     
}
项目:hadoop-plus    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-plus    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(
        req.getSrc(), PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
            req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:FlexMap    文件:PBHelper.java   
public static DatanodeInfoProto convert(DatanodeInfo info) {
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (info.getNetworkLocation() != null) {
    builder.setLocation(info.getNetworkLocation());
  }
  builder
      .setId(PBHelper.convert((DatanodeID)info))
      .setCapacity(info.getCapacity())
      .setDfsUsed(info.getDfsUsed())
      .setRemaining(info.getRemaining())
      .setBlockPoolUsed(info.getBlockPoolUsed())
      .setCacheCapacity(info.getCacheCapacity())
      .setCacheUsed(info.getCacheUsed())
      .setLastUpdate(info.getLastUpdate())
      .setXceiverCount(info.getXceiverCount())
      .setAdminState(PBHelper.convert(info.getAdminState()))
      .build();
  return builder.build();
}
项目:FlexMap    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:FlexMap    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<String> existingStorageIDsList = req.getExistingStorageUuidsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(req.getSrc(),
        req.getFileId(), PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        existingStorageIDsList.toArray(
            new String[existingStorageIDsList.size()]),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
        req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hops    文件:PBHelper.java   
static public DatanodeInfoProto convertDatanodeInfo(DatanodeInfo di) {
  if (di == null) {
    return null;
  }
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (di.getNetworkLocation() != null) {
    builder.setLocation(di.getNetworkLocation());
  }

  return builder.
      setId(PBHelper.convert((DatanodeID) di)).
      setCapacity(di.getCapacity()).
      setDfsUsed(di.getDfsUsed()).
      setRemaining(di.getRemaining()).
      setBlockPoolUsed(di.getBlockPoolUsed()).
      setLastUpdate(di.getLastUpdate()).
      setXceiverCount(di.getXceiverCount()).
      setAdminState(PBHelper.convert(di.getAdminState())).
      build();
}
项目:hops    文件:PBHelper.java   
public static LocatedBlock convert(LocatedBlockProto proto) {
  if (proto == null) {
    return null;
  }
  List<DatanodeInfoProto> locs = proto.getLocsList();
  DatanodeInfo[] targets = new DatanodeInfo[locs.size()];
  for (int i = 0; i < locs.size(); i++) {
    targets[i] = PBHelper.convert(locs.get(i));
  }
  LocatedBlock lb = new LocatedBlock(PBHelper.convert(proto.getB()), targets,
      proto.getOffset(), proto.getCorrupt());
  lb.setBlockToken(PBHelper.convert(proto.getBlockToken()));
  if(proto.getData().size() > 0){
    lb.setData(proto.getData().toByteArray());
  }
  return lb;
}
项目:hops    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    LocatedBlock result = server.addBlock(req.getSrc(), req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper
            .convert(excl.toArray(new DatanodeInfoProto[excl.size()])));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hops    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server
        .getAdditionalDatanode(req.getSrc(), PBHelper.convert(req.getBlk()),
            PBHelper.convert(existingList
                .toArray(new DatanodeInfoProto[existingList.size()])),
            PBHelper.convert(excludesList
                .toArray(new DatanodeInfoProto[excludesList.size()])),
            req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-TCP    文件:PBHelper.java   
static public DatanodeInfoProto convertDatanodeInfo(DatanodeInfo di) {
  if (di == null) return null;
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (di.getNetworkLocation() != null) {
    builder.setLocation(di.getNetworkLocation());
  }

  return builder.
   setId(PBHelper.convert((DatanodeID) di)).
   setCapacity(di.getCapacity()).
   setDfsUsed(di.getDfsUsed()).
   setRemaining(di.getRemaining()).
   setBlockPoolUsed(di.getBlockPoolUsed()).
   setLastUpdate(di.getLastUpdate()).
   setXceiverCount(di.getXceiverCount()).
   setAdminState(PBHelper.convert(di.getAdminState())).
   build();     
}
项目:hadoop-TCP    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-TCP    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(
        req.getSrc(), PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
            req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hardfs    文件:PBHelper.java   
static public DatanodeInfoProto convertDatanodeInfo(DatanodeInfo di) {
  if (di == null) return null;
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (di.getNetworkLocation() != null) {
    builder.setLocation(di.getNetworkLocation());
  }

  return builder.
   setId(PBHelper.convert((DatanodeID) di)).
   setCapacity(di.getCapacity()).
   setDfsUsed(di.getDfsUsed()).
   setRemaining(di.getRemaining()).
   setBlockPoolUsed(di.getBlockPoolUsed()).
   setLastUpdate(di.getLastUpdate()).
   setXceiverCount(di.getXceiverCount()).
   setAdminState(PBHelper.convert(di.getAdminState())).
   build();     
}
项目:hardfs    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hardfs    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(
        req.getSrc(), PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
            req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-on-lustre2    文件:PBHelper.java   
public static DatanodeInfoProto convert(DatanodeInfo info) {
  DatanodeInfoProto.Builder builder = DatanodeInfoProto.newBuilder();
  if (info.getNetworkLocation() != null) {
    builder.setLocation(info.getNetworkLocation());
  }
  builder
      .setId(PBHelper.convert((DatanodeID)info))
      .setCapacity(info.getCapacity())
      .setDfsUsed(info.getDfsUsed())
      .setRemaining(info.getRemaining())
      .setBlockPoolUsed(info.getBlockPoolUsed())
      .setCacheCapacity(info.getCacheCapacity())
      .setCacheUsed(info.getCacheUsed())
      .setLastUpdate(info.getLastUpdate())
      .setXceiverCount(info.getXceiverCount())
      .setAdminState(PBHelper.convert(info.getAdminState()))
      .build();
  return builder.build();
}
项目:hadoop-on-lustre2    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public AddBlockResponseProto addBlock(RpcController controller,
    AddBlockRequestProto req) throws ServiceException {

  try {
    List<DatanodeInfoProto> excl = req.getExcludeNodesList();
    List<String> favor = req.getFavoredNodesList();
    LocatedBlock result = server.addBlock(
        req.getSrc(),
        req.getClientName(),
        req.hasPrevious() ? PBHelper.convert(req.getPrevious()) : null,
        (excl == null || excl.size() == 0) ? null : PBHelper.convert(excl
            .toArray(new DatanodeInfoProto[excl.size()])), req.getFileId(),
        (favor == null || favor.size() == 0) ? null : favor
            .toArray(new String[favor.size()]));
    return AddBlockResponseProto.newBuilder()
        .setBlock(PBHelper.convert(result)).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop-on-lustre2    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetAdditionalDatanodeResponseProto getAdditionalDatanode(
    RpcController controller, GetAdditionalDatanodeRequestProto req)
    throws ServiceException {
  try {
    List<DatanodeInfoProto> existingList = req.getExistingsList();
    List<String> existingStorageIDsList = req.getExistingStorageUuidsList();
    List<DatanodeInfoProto> excludesList = req.getExcludesList();
    LocatedBlock result = server.getAdditionalDatanode(req.getSrc(),
        PBHelper.convert(req.getBlk()),
        PBHelper.convert(existingList.toArray(
            new DatanodeInfoProto[existingList.size()])),
        existingStorageIDsList.toArray(
            new String[existingStorageIDsList.size()]),
        PBHelper.convert(excludesList.toArray(
            new DatanodeInfoProto[excludesList.size()])), 
        req.getNumAdditionalNodes(), req.getClientName());
    return GetAdditionalDatanodeResponseProto.newBuilder().setBlock(
        PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:hadoop    文件:PBHelper.java   
public static DatanodeInfoProto.AdminState convert(
    final DatanodeInfo.AdminStates inAs) {
  switch (inAs) {
  case NORMAL: return  DatanodeInfoProto.AdminState.NORMAL;
  case DECOMMISSION_INPROGRESS: 
      return DatanodeInfoProto.AdminState.DECOMMISSION_INPROGRESS;
  case DECOMMISSIONED: return DatanodeInfoProto.AdminState.DECOMMISSIONED;
  default: return DatanodeInfoProto.AdminState.NORMAL;
  }
}
项目:hadoop    文件:PBHelper.java   
static public DatanodeInfo convert(DatanodeInfoProto di) {
  if (di == null) return null;
  return new DatanodeInfo(
      PBHelper.convert(di.getId()),
      di.hasLocation() ? di.getLocation() : null , 
      di.getCapacity(),  di.getDfsUsed(),  di.getRemaining(),
      di.getBlockPoolUsed(), di.getCacheCapacity(), di.getCacheUsed(),
      di.getLastUpdate(), di.getLastUpdateMonotonic(),
      di.getXceiverCount(), PBHelper.convert(di.getAdminState()));
}
项目:hadoop    文件:PBHelper.java   
static public DatanodeInfo[] convert(DatanodeInfoProto di[]) {
  if (di == null) return null;
  DatanodeInfo[] result = new DatanodeInfo[di.length];
  for (int i = 0; i < di.length; i++) {
    result[i] = convert(di[i]);
  }    
  return result;
}
项目:hadoop    文件:PBHelper.java   
/**
 * Copy from {@code dnInfos} to a target of list of same size starting at
 * {@code startIdx}.
 */
public static List<? extends HdfsProtos.DatanodeInfoProto> convert(
    DatanodeInfo[] dnInfos, int startIdx) {
  if (dnInfos == null)
    return null;
  ArrayList<HdfsProtos.DatanodeInfoProto> protos = Lists
      .newArrayListWithCapacity(dnInfos.length);
  for (int i = startIdx; i < dnInfos.length; i++) {
    protos.add(convert(dnInfos[i]));
  }
  return protos;
}
项目:hadoop    文件:PBHelper.java   
public static DatanodeInfo[] convert(List<DatanodeInfoProto> list) {
  DatanodeInfo[] info = new DatanodeInfo[list.size()];
  for (int i = 0; i < info.length; i++) {
    info[i] = convert(list.get(i));
  }
  return info;
}
项目:hadoop    文件:PBHelper.java   
public static LocatedBlock convert(LocatedBlockProto proto) {
  if (proto == null) return null;
  List<DatanodeInfoProto> locs = proto.getLocsList();
  DatanodeInfo[] targets = new DatanodeInfo[locs.size()];
  for (int i = 0; i < locs.size(); i++) {
    targets[i] = PBHelper.convert(locs.get(i));
  }

  final StorageType[] storageTypes = convertStorageTypes(
      proto.getStorageTypesList(), locs.size());

  final int storageIDsCount = proto.getStorageIDsCount();
  final String[] storageIDs;
  if (storageIDsCount == 0) {
    storageIDs = null;
  } else {
    Preconditions.checkState(storageIDsCount == locs.size());
    storageIDs = proto.getStorageIDsList().toArray(new String[storageIDsCount]);
  }

  // Set values from the isCached list, re-using references from loc
  List<DatanodeInfo> cachedLocs = new ArrayList<DatanodeInfo>(locs.size());
  List<Boolean> isCachedList = proto.getIsCachedList();
  for (int i=0; i<isCachedList.size(); i++) {
    if (isCachedList.get(i)) {
      cachedLocs.add(targets[i]);
    }
  }

  LocatedBlock lb = new LocatedBlock(PBHelper.convert(proto.getB()), targets,
      storageIDs, storageTypes, proto.getOffset(), proto.getCorrupt(),
      cachedLocs.toArray(new DatanodeInfo[0]));
  lb.setBlockToken(PBHelper.convert(proto.getBlockToken()));

  return lb;
}
项目:hadoop    文件:PBHelper.java   
public static DatanodeInfo[] convert(DatanodeInfosProto datanodeInfosProto) {
  List<DatanodeInfoProto> proto = datanodeInfosProto.getDatanodesList();
  DatanodeInfo[] infos = new DatanodeInfo[proto.size()];
  for (int i = 0; i < infos.length; i++) {
    infos[i] = PBHelper.convert(proto.get(i));
  }
  return infos;
}
项目:hadoop    文件:ClientNamenodeProtocolServerSideTranslatorPB.java   
@Override
public GetDatanodeReportResponseProto getDatanodeReport(
    RpcController controller, GetDatanodeReportRequestProto req)
    throws ServiceException {
  try {
    List<? extends DatanodeInfoProto> result = PBHelper.convert(server
        .getDatanodeReport(PBHelper.convert(req.getType())));
    return GetDatanodeReportResponseProto.newBuilder()
        .addAllDi(result).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
项目:aliyun-oss-hadoop-fs    文件:PBHelperClient.java   
public static DatanodeInfoProto.AdminState convert(
    final DatanodeInfo.AdminStates inAs) {
  switch (inAs) {
  case NORMAL: return  DatanodeInfoProto.AdminState.NORMAL;
  case DECOMMISSION_INPROGRESS:
    return DatanodeInfoProto.AdminState.DECOMMISSION_INPROGRESS;
  case DECOMMISSIONED: return DatanodeInfoProto.AdminState.DECOMMISSIONED;
  default: return DatanodeInfoProto.AdminState.NORMAL;
  }
}