当前位置: 首页>>代码示例>>Java>>正文


Java ProtobufHelper类代码示例

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


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

示例1: getServiceStatus

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public HAServiceStatus getServiceStatus() throws IOException {
  GetServiceStatusResponseProto status;
  try {
    status = rpcProxy.getServiceStatus(NULL_CONTROLLER,
        GET_SERVICE_STATUS_REQ);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  
  HAServiceStatus ret = new HAServiceStatus(
      convert(status.getState()));
  if (status.getReadyToBecomeActive()) {
    ret.setReadyToBecomeActive();
  } else {
    ret.setNotReadyToBecomeActive(status.getNotReadyReason());
  }
  return ret;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:HAServiceProtocolClientSideTranslatorPB.java

示例2: listSpanReceivers

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public SpanReceiverInfo[] listSpanReceivers() throws IOException {
  ArrayList<SpanReceiverInfo> infos = new ArrayList<SpanReceiverInfo>(1);
  try {
    ListSpanReceiversRequestProto req =
        ListSpanReceiversRequestProto.newBuilder().build();
    ListSpanReceiversResponseProto resp =
        rpcProxy.listSpanReceivers(null, req);
    for (SpanReceiverListInfo info : resp.getDescriptionsList()) {
      infos.add(new SpanReceiverInfo(info.getId(), info.getClassName()));
    }
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  return infos.toArray(new SpanReceiverInfo[infos.size()]);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TraceAdminProtocolTranslatorPB.java

示例3: initReplicaRecovery

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public ReplicaRecoveryInfo initReplicaRecovery(RecoveringBlock rBlock)
    throws IOException {
  InitReplicaRecoveryRequestProto req = InitReplicaRecoveryRequestProto
      .newBuilder().setBlock(PBHelper.convert(rBlock)).build();
  InitReplicaRecoveryResponseProto resp;
  try {
    resp = rpcProxy.initReplicaRecovery(NULL_CONTROLLER, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  if (!resp.getReplicaFound()) {
    // No replica found on the remote node.
    return null;
  } else {
    if (!resp.hasBlock() || !resp.hasState()) {
      throw new IOException("Replica was found but missing fields. " +
          "Req: " + req + "\n" +
          "Resp: " + resp);
    }
  }
  
  BlockProto b = resp.getBlock();
  return new ReplicaRecoveryInfo(b.getBlockId(), b.getNumBytes(),
      b.getGenStamp(), PBHelper.convert(resp.getState()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:InterDatanodeProtocolTranslatorPB.java

示例4: cacheReport

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public DatanodeCommand cacheReport(DatanodeRegistration registration,
    String poolId, List<Long> blockIds) throws IOException {
  CacheReportRequestProto.Builder builder =
      CacheReportRequestProto.newBuilder()
      .setRegistration(PBHelper.convert(registration))
      .setBlockPoolId(poolId);
  for (Long blockId : blockIds) {
    builder.addBlocks(blockId);
  }
  
  CacheReportResponseProto resp;
  try {
    resp = rpcProxy.cacheReport(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
  if (resp.hasCmd()) {
    return PBHelper.convert(resp.getCmd());
  }
  return null;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:DatanodeProtocolClientSideTranslatorPB.java

示例5: blockReceivedAndDeleted

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public void blockReceivedAndDeleted(DatanodeRegistration registration,
    String poolId, StorageReceivedDeletedBlocks[] receivedAndDeletedBlocks)
    throws IOException {
  BlockReceivedAndDeletedRequestProto.Builder builder = 
      BlockReceivedAndDeletedRequestProto.newBuilder()
      .setRegistration(PBHelper.convert(registration))
      .setBlockPoolId(poolId);
  for (StorageReceivedDeletedBlocks storageBlock : receivedAndDeletedBlocks) {
    StorageReceivedDeletedBlocksProto.Builder repBuilder = 
        StorageReceivedDeletedBlocksProto.newBuilder();
    repBuilder.setStorageUuid(storageBlock.getStorage().getStorageID());  // Set for wire compatibility.
    repBuilder.setStorage(PBHelper.convert(storageBlock.getStorage()));
    for (ReceivedDeletedBlockInfo rdBlock : storageBlock.getBlocks()) {
      repBuilder.addBlocks(PBHelper.convert(rdBlock));
    }
    builder.addBlocks(repBuilder.build());
  }
  try {
    rpcProxy.blockReceivedAndDeleted(NULL_CONTROLLER, builder.build());
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:DatanodeProtocolClientSideTranslatorPB.java

示例6: addSpanReceiver

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public long addSpanReceiver(SpanReceiverInfo info) throws IOException {
  try {
    AddSpanReceiverRequestProto.Builder bld =
        AddSpanReceiverRequestProto.newBuilder();
    bld.setClassName(info.getClassName());
    for (ConfigurationPair configPair : info.configPairs) {
      ConfigPair tuple = ConfigPair.newBuilder().
          setKey(configPair.getKey()).
          setValue(configPair.getValue()).build();
      bld.addConfig(tuple);
    }
    AddSpanReceiverResponseProto resp =
        rpcProxy.addSpanReceiver(null, bld.build());
    return resp.getId();
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TraceAdminProtocolTranslatorPB.java

示例7: createEncryptionZone

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public void createEncryptionZone(String src, String keyName)
  throws IOException {
  final CreateEncryptionZoneRequestProto.Builder builder =
    CreateEncryptionZoneRequestProto.newBuilder();
  builder.setSrc(src);
  if (keyName != null && !keyName.isEmpty()) {
    builder.setKeyName(keyName);
  }
  CreateEncryptionZoneRequestProto req = builder.build();
  try {
    rpcProxy.createEncryptionZone(null, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:ClientNamenodeProtocolTranslatorPB.java

示例8: getBlockLocalPathInfo

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public BlockLocalPathInfo getBlockLocalPathInfo(ExtendedBlock block,
    Token<BlockTokenIdentifier> token) throws IOException {
  GetBlockLocalPathInfoRequestProto req =
      GetBlockLocalPathInfoRequestProto.newBuilder()
      .setBlock(PBHelper.convert(block))
      .setToken(PBHelper.convert(token)).build();
  GetBlockLocalPathInfoResponseProto resp;
  try {
    resp = rpcProxy.getBlockLocalPathInfo(NULL_CONTROLLER, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
  return new BlockLocalPathInfo(PBHelper.convert(resp.getBlock()),
      resp.getLocalPath(), resp.getLocalMetaPath());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:ClientDatanodeProtocolTranslatorPB.java

示例9: listEncryptionZones

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public BatchedEntries<EncryptionZone> listEncryptionZones(long id)
    throws IOException {
  final ListEncryptionZonesRequestProto req =
    ListEncryptionZonesRequestProto.newBuilder()
        .setId(id)
        .build();
  try {
    EncryptionZonesProtos.ListEncryptionZonesResponseProto response =
        rpcProxy.listEncryptionZones(null, req);
    List<EncryptionZone> elements =
        Lists.newArrayListWithCapacity(response.getZonesCount());
    for (EncryptionZoneProto p : response.getZonesList()) {
      elements.add(PBHelper.convert(p));
    }
    return new BatchedListEntries<EncryptionZone>(elements,
        response.getHasMore());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ClientNamenodeProtocolTranslatorPB.java

示例10: append

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public LastBlockWithStatus append(String src, String clientName,
    EnumSetWritable<CreateFlag> flag) throws AccessControlException,
    DSQuotaExceededException, FileNotFoundException, SafeModeException,
    UnresolvedLinkException, IOException {
  AppendRequestProto req = AppendRequestProto.newBuilder().setSrc(src)
      .setClientName(clientName).setFlag(PBHelper.convertCreateFlag(flag))
      .build();
  try {
    AppendResponseProto res = rpcProxy.append(null, req);
    LocatedBlock lastBlock = res.hasBlock() ? PBHelper
        .convert(res.getBlock()) : null;
    HdfsFileStatus stat = (res.hasStat()) ? PBHelper.convert(res.getStat())
        : null;
    return new LastBlockWithStatus(lastBlock, stat);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:ClientNamenodeProtocolTranslatorPB.java

示例11: complete

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public boolean complete(String src, String clientName,
                        ExtendedBlock last, long fileId)
    throws AccessControlException, FileNotFoundException, SafeModeException,
    UnresolvedLinkException, IOException {
  CompleteRequestProto.Builder req = CompleteRequestProto.newBuilder()
      .setSrc(src)
      .setClientName(clientName)
      .setFileId(fileId);
  if (last != null)
    req.setLast(PBHelper.convert(last));
  try {
    return rpcProxy.complete(null, req.build()).getResult();
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:ClientNamenodeProtocolTranslatorPB.java

示例12: rename2

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public void rename2(String src, String dst, Rename... options)
    throws AccessControlException, DSQuotaExceededException,
    FileAlreadyExistsException, FileNotFoundException,
    NSQuotaExceededException, ParentNotDirectoryException, SafeModeException,
    UnresolvedLinkException, IOException {
  boolean overwrite = false;
  if (options != null) {
    for (Rename option : options) {
      if (option == Rename.OVERWRITE) {
        overwrite = true;
      }
    }
  }
  Rename2RequestProto req = Rename2RequestProto.newBuilder().
      setSrc(src).
      setDst(dst).setOverwriteDest(overwrite).
      build();
  try {
    rpcProxy.rename2(null, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }

}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:ClientNamenodeProtocolTranslatorPB.java

示例13: refresh

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public Collection<RefreshResponse> refresh(String identifier, String[] args) throws IOException {
  List<String> argList = Arrays.asList(args);

  try {
    GenericRefreshRequestProto request = GenericRefreshRequestProto.newBuilder()
      .setIdentifier(identifier)
      .addAllArgs(argList)
      .build();

    GenericRefreshResponseCollectionProto resp = rpcProxy.refresh(NULL_CONTROLLER, request);
    return unpack(resp);
  } catch (ServiceException se) {
    throw ProtobufHelper.getRemoteException(se);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:GenericRefreshProtocolClientSideTranslatorPB.java

示例14: journal

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public void journal(RequestInfo reqInfo,
    long segmentTxId, long firstTxnId, int numTxns,
    byte[] records) throws IOException {
  JournalRequestProto req = JournalRequestProto.newBuilder()
      .setReqInfo(convert(reqInfo))
      .setSegmentTxnId(segmentTxId)
      .setFirstTxnId(firstTxnId)
      .setNumTxns(numTxns)
      .setRecords(PBHelper.getByteString(records))
      .build();
  try {
    rpcProxy.journal(NULL_CONTROLLER, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:QJournalProtocolTranslatorPB.java

示例15: setQuota

import org.apache.hadoop.ipc.ProtobufHelper; //导入依赖的package包/类
@Override
public void setQuota(String path, long namespaceQuota, long storagespaceQuota,
                     StorageType type)
    throws AccessControlException, FileNotFoundException,
    UnresolvedLinkException, IOException {
  final SetQuotaRequestProto.Builder builder
      = SetQuotaRequestProto.newBuilder()
      .setPath(path)
      .setNamespaceQuota(namespaceQuota)
      .setStoragespaceQuota(storagespaceQuota);
  if (type != null) {
    builder.setStorageType(PBHelper.convertStorageType(type));
  }
  final SetQuotaRequestProto req = builder.build();
  try {
    rpcProxy.setQuota(null, req);
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:ClientNamenodeProtocolTranslatorPB.java


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