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


Java RpcController类代码示例

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


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

示例1: getMatrices

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * Get matrices metadata
 * @param controller
 * @param request
 * @return
 * @throws ServiceException
 */
@Override
public GetMatricesResponse getMatrices(RpcController controller, GetMatricesRequest request)
  throws ServiceException {
  GetMatricesResponse.Builder builder = GetMatricesResponse.newBuilder();
  AMMatrixMetaManager matrixMetaManager = context.getMatrixMetaManager();

  List<String> matrixNames = request.getMatrixNamesList();
  int size = matrixNames.size();
  for(int i = 0; i < size; i++) {
    MatrixMeta matrixMeta = matrixMetaManager.getMatrix(matrixNames.get(i));
    if(matrixMeta == null) {
      throw new ServiceException("Can not find matrix " + matrixNames.get(i));
    }
    builder.addMatrixMetas(ProtobufUtil.convertToMatrixMetaProto(matrixMeta));
  }
  return builder.build();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:25,代码来源:MasterService.java

示例2: psError

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * notify a parameter server run failed
 * @param controller rpc controller of protobuf
 * @param request contains parameter server id and error message
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
@Override
public PSErrorResponse psError(RpcController controller, PSErrorRequest request)
    throws ServiceException {
  PSAttemptId psAttemptId = ProtobufUtil.convertToId(request.getPsAttemptId());
  LOG.info("error happened in psAttempt " + psAttemptId + " error msg=" + request.getMsg());

  //remove this parameter server attempt from monitor set
  psLastHeartbeatTS.remove(psAttemptId);

  context.getEventHandler().handle(
      new PSAttemptDiagnosticsUpdateEvent(request.getMsg(), psAttemptId));

  context.getEventHandler()
      .handle(new PSAttemptEvent(PSAttemptEventType.PA_FAILMSG, psAttemptId));

  return PSErrorResponse.newBuilder().build();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:25,代码来源:MasterService.java

示例3: create

import com.google.protobuf.RpcController; //导入依赖的package包/类
@Override
public CreateResponseProto create(RpcController controller,
    CreateRequestProto req) throws ServiceException {
  try {
    HdfsFileStatus result = server.create(req.getSrc(),
        PBHelper.convert(req.getMasked()), req.getClientName(),
        PBHelper.convertCreateFlag(req.getCreateFlag()), req.getCreateParent(),
        (short) req.getReplication(), req.getBlockSize(),
        PBHelper.convertCryptoProtocolVersions(
            req.getCryptoProtocolVersionList()));

    if (result != null) {
      return CreateResponseProto.newBuilder().setFs(PBHelper.convert(result))
          .build();
    }
    return VOID_CREATE_RESPONSE;
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:ClientNamenodeProtocolServerSideTranslatorPB.java

示例4: getPartLocation

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * Get locations for a partition
 * @param controller
 * @param request
 * @return
 * @throws ServiceException
 */
@Override public GetPartLocationResponse getPartLocation(RpcController controller,
  GetPartLocationRequest request) throws ServiceException {
  GetPartLocationResponse.Builder builder = GetPartLocationResponse.newBuilder();
  List<ParameterServerId> psIds = context.getMatrixMetaManager().getPss(request.getMatrixId(), request.getPartId());

  if(psIds != null) {
    int size = psIds.size();
    for(int i = 0; i < size; i++) {
      Location psLocation = context.getLocationManager().getPsLocation(psIds.get(i));
      if (psLocation == null) {
        builder.addLocations((PSLocationProto.newBuilder().setPsId(
          ProtobufUtil.convertToIdProto(psIds.get(i))).setPsStatus(PSStatus.PS_NOTREADY).build()));
      } else {
        builder.addLocations(ProtobufUtil.convertToPSLocProto(psIds.get(i), psLocation));
      }
    }
  }

  return builder.build();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:28,代码来源:MasterService.java

示例5: psAgentReport

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * response for psagent heartbeat.
 *
 * @param controller rpc controller of protobuf
 * @param request
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
@Override
public PSAgentReportResponse psAgentReport(RpcController controller, PSAgentReportRequest request)
    throws ServiceException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("receive ps agent state report, request=" + request);
  }
  PSAgentAttemptId psAgentAttemptId = ProtobufUtil.convertToId(request.getPsAgentAttemptId());

  if (!psAgentLastHeartbeatTS.containsKey(psAgentAttemptId)) {
    LOG.error("psagent attempt " + psAgentAttemptId + " is not in running worker attempt set now, shutdown it");
    return PSAgentReportResponse.newBuilder().setCommand(PSAgentCommandProto.PSAGENT_SHUTDOWN)
        .build();

  } else {
    context.getEventHandler().handle(
        new PSAgentAttemptStateUpdateEvent(psAgentAttemptId, request));
    psAgentLastHeartbeatTS.put(psAgentAttemptId, System.currentTimeMillis());
    return PSAgentReportResponse.newBuilder().setCommand(PSAgentCommandProto.PSAGENT_SUCCESS)
        .build();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:30,代码来源:MasterService.java

示例6: psAgentError

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * psagent run falied
 *
 * @param controller rpc controller of protobuf
 * @param request contains psagent attempt id, error message
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
@Override
public PSAgentErrorResponse psAgentError(RpcController controller, PSAgentErrorRequest request)
    throws ServiceException {
  PSAgentErrorResponse.Builder resBuilder = PSAgentErrorResponse.newBuilder();
  PSAgentAttemptId psAgentAttemptId = ProtobufUtil.convertToId(request.getPsAgentAttemptId());

  if (!psAgentLastHeartbeatTS.containsKey(psAgentAttemptId)) {
    LOG.error("psagent attempt " + psAgentAttemptId + " is not in running worker attempt set now, shutdown it");
    resBuilder.setCommand(PSAgentCommandProto.PSAGENT_SHUTDOWN);
  } else {
    psAgentLastHeartbeatTS.remove(psAgentAttemptId);
    LOG.error("error happened in psagent " + psAgentAttemptId + ", error msg:" + request.getMsg());
    context.getEventHandler().handle(
        new PSAgentAttemptDiagnosticsUpdateEvent(psAgentAttemptId, request.getMsg()));
    context.getEventHandler()
        .handle(
            new PSAgentAttemptEvent(PSAgentAttemptEventType.PSAGENT_ATTEMPT_FAILMSG,
                psAgentAttemptId));
    resBuilder.setCommand(PSAgentCommandProto.PSAGENT_SUCCESS);
  }
  return resBuilder.build();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:31,代码来源:MasterService.java

示例7: workerRegister

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * worker register to master
 *
 * @param controller rpc controller of protobuf
 * @param request contains worker attempt id, worker location
 * @throws ServiceException
 */
@SuppressWarnings("unchecked")
@Override
public WorkerRegisterResponse workerRegister(RpcController controller,
    WorkerRegisterRequest request) throws ServiceException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("receive worker register, request=" + request);
  }
  WorkerRegisterResponse.Builder registerResponseBuilder = WorkerRegisterResponse.newBuilder();
  WorkerAttemptId workerAttemptId = ProtobufUtil.convertToId(request.getWorkerAttemptId());

  //if worker attempt id is not in monitor set, we should shutdown it
  if (!workerLastHeartbeatTS.containsKey(workerAttemptId)) {
    LOG.error("worker attempt " + workerAttemptId + " is not in running worker attempt set now, shutdown it");
    registerResponseBuilder.setCommand(WorkerCommandProto.W_SHUTDOWN);
  } else {
    Location location =
        new Location(request.getLocation().getIp(), request.getLocation().getPort());
    context.getEventHandler().handle(new WorkerAttemptRegisterEvent(workerAttemptId, location));
    registerResponseBuilder.setCommand(WorkerCommandProto.W_SUCCESS);

    LOG.info("worker attempt " + workerAttemptId + " register finished!");
  }

  return registerResponseBuilder.build();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:33,代码来源:MasterService.java

示例8: checkMatricesCreated

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * Check matrices are created successfully
 * @param controller rpc controller of protobuf
 * @param request check request that contains matrix names
 */
@Override
public CheckMatricesCreatedResponse checkMatricesCreated(RpcController controller,
    CheckMatricesCreatedRequest request) throws ServiceException {
  List<String> names = request.getMatrixNamesList();
  CheckMatricesCreatedResponse.Builder builder = CheckMatricesCreatedResponse.newBuilder();
  int size = names.size();
  for(int i = 0; i < size; i++) {
    if(!context.getMatrixMetaManager().isCreated(names.get(i))) {
      builder.setStatus(-1);
      return builder.build();
    }
  }

  return builder.setStatus(0).build();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:21,代码来源:MasterService.java

示例9: rollWALWriter

import com.google.protobuf.RpcController; //导入依赖的package包/类
/**
 * Roll the WAL writer of the region server.
 * @param controller the RPC controller
 * @param request the request
 * @throws ServiceException
 */
@Override
public RollWALWriterResponse rollWALWriter(final RpcController controller,
    final RollWALWriterRequest request) throws ServiceException {
  try {
    checkOpen();
    requestCount.increment();
    regionServer.getRegionServerCoprocessorHost().preRollWALWriterRequest();
    regionServer.walRoller.requestRollAll();
    regionServer.getRegionServerCoprocessorHost().postRollWALWriterRequest();
    RollWALWriterResponse.Builder builder = RollWALWriterResponse.newBuilder();
    return builder.build();
  } catch (IOException ie) {
    throw new ServiceException(ie);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:RSRpcServices.java

示例10: refresh

import com.google.protobuf.RpcController; //导入依赖的package包/类
@Override
public GenericRefreshResponseCollectionProto refresh(
    RpcController controller, GenericRefreshRequestProto request)
    throws ServiceException {
  try {
    List<String> argList = request.getArgsList();
    String[] args = argList.toArray(new String[argList.size()]);

    if (!request.hasIdentifier()) {
      throw new ServiceException("Request must contain identifier");
    }

    Collection<RefreshResponse> results = impl.refresh(request.getIdentifier(), args);

    return pack(results);
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:GenericRefreshProtocolServerSideTranslatorPB.java

示例11: addSpanReceiver

import com.google.protobuf.RpcController; //导入依赖的package包/类
@Override
public AddSpanReceiverResponseProto addSpanReceiver(
    RpcController controller, AddSpanReceiverRequestProto req)
        throws ServiceException {
  try {
    SpanReceiverInfoBuilder factory =
      new SpanReceiverInfoBuilder(req.getClassName());
    for (ConfigPair config : req.getConfigList()) {
      factory.addConfigurationPair(config.getKey(), config.getValue());
    }
    long id = server.addSpanReceiver(factory.build());
    return AddSpanReceiverResponseProto.newBuilder().setId(id).build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TraceAdminProtocolServerSideTranslatorPB.java

示例12: getSnapshottableDirListing

import com.google.protobuf.RpcController; //导入依赖的package包/类
@Override
public GetSnapshottableDirListingResponseProto getSnapshottableDirListing(
    RpcController controller, GetSnapshottableDirListingRequestProto request)
    throws ServiceException {
  try {
    SnapshottableDirectoryStatus[] result = server
        .getSnapshottableDirListing();
    if (result != null) {
      return GetSnapshottableDirListingResponseProto.newBuilder().
          setSnapshottableDirList(PBHelper.convert(result)).build();
    } else {
      return NULL_GET_SNAPSHOTTABLE_DIR_LISTING_RESPONSE;
    }
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:ClientNamenodeProtocolServerSideTranslatorPB.java

示例13: append

import com.google.protobuf.RpcController; //导入依赖的package包/类
@Override
public AppendResponseProto append(RpcController controller,
    AppendRequestProto req) throws ServiceException {
  try {
    EnumSetWritable<CreateFlag> flags = req.hasFlag() ?
        PBHelper.convertCreateFlag(req.getFlag()) :
        new EnumSetWritable<>(EnumSet.of(CreateFlag.APPEND));
    LastBlockWithStatus result = server.append(req.getSrc(),
        req.getClientName(), flags);
    AppendResponseProto.Builder builder = AppendResponseProto.newBuilder();
    if (result.getLastBlock() != null) {
      builder.setBlock(PBHelper.convert(result.getLastBlock()));
    }
    if (result.getFileStatus() != null) {
      builder.setStat(PBHelper.convert(result.getFileStatus()));
    }
    return builder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ClientNamenodeProtocolServerSideTranslatorPB.java

示例14: callBlockingMethod

import com.google.protobuf.RpcController; //导入依赖的package包/类
@Override
public Message callBlockingMethod(Descriptors.MethodDescriptor md, RpcController controller,
    Message param, Message returnType) throws ServiceException {
  PayloadCarryingRpcController pcrc;
  if (controller != null && controller instanceof PayloadCarryingRpcController) {
    pcrc = (PayloadCarryingRpcController) controller;
    if (!pcrc.hasCallTimeout()) {
      pcrc.setCallTimeout(channelOperationTimeout);
    }
  } else {
    pcrc = new PayloadCarryingRpcController();
    pcrc.setCallTimeout(channelOperationTimeout);
  }

  return this.rpcClient.callBlockingMethod(md, pcrc, param, returnType, this.ticket, this.isa);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:AbstractRpcClient.java

示例15: getProtocolVersions

import com.google.protobuf.RpcController; //导入依赖的package包/类
@Override
public GetProtocolVersionsResponseProto getProtocolVersions(
    RpcController controller, GetProtocolVersionsRequestProto request)
    throws ServiceException {
  String protocol = request.getProtocol();
  GetProtocolVersionsResponseProto.Builder builder = 
      GetProtocolVersionsResponseProto.newBuilder();
  for (RPC.RpcKind r : RPC.RpcKind.values()) {
    long[] versions;
    try {
      versions = getProtocolVersionForRpcKind(r, protocol);
    } catch (ClassNotFoundException e) {
      throw new ServiceException(e);
    }
    ProtocolVersionProto.Builder b = ProtocolVersionProto.newBuilder();
    if (versions != null) {
      b.setRpcKind(r.toString());
      for (long v : versions) {
        b.addVersions(v);
      }
    }
    builder.addProtocolVersions(b.build());
  }
  return builder.build();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:26,代码来源:ProtocolMetaInfoServerSideTranslatorPB.java


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