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


Java RPCUtil类代码示例

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


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

示例1: startContainers

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public StartContainersResponse startContainers(
    StartContainersRequest requests) throws YarnException {
  StartContainersResponse response =
      recordFactory.newRecordInstance(StartContainersResponse.class);
  for (StartContainerRequest request : requests.getStartContainerRequests()) {
    Token containerToken = request.getContainerToken();
    ContainerTokenIdentifier tokenId = null;

    try {
      tokenId = newContainerTokenIdentifier(containerToken);
    } catch (IOException e) {
      throw RPCUtil.getRemoteException(e);
    }
    ContainerStatus status =
        recordFactory.newRecordInstance(ContainerStatus.class);
    status.setState(ContainerState.RUNNING);
    status.setContainerId(tokenId.getContainerID());
    status.setExitStatus(0);
    statuses.add(status);

  }
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRPC.java

示例2: checkAcls

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
private void checkAcls(String method) throws YarnException {
  UserGroupInformation user;
  try {
    user = UserGroupInformation.getCurrentUser();
  } catch (IOException ioe) {
    LOG.warn("Couldn't get current user", ioe);
    throw RPCUtil.getRemoteException(ioe);
  }

  if (!authorizer.isAdmin(user)) {
    LOG.warn("User " + user.getShortUserName() + " doesn't have permission" +
        " to call '" + method + "'");

    throw RPCUtil.getRemoteException(
        new AccessControlException("User " + user.getShortUserName() +
        " doesn't have permission" + " to call '" + method + "'"));
  }
  LOG.info("SCM Admin: " + method + " invoked by user " +
      user.getShortUserName());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:SCMAdminProtocolService.java

示例3: getContainerStatusInternal

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
private ContainerStatus getContainerStatusInternal(ContainerId containerID,
    NMTokenIdentifier nmTokenIdentifier) throws YarnException {
  String containerIDStr = containerID.toString();
  Container container = this.context.getContainers().get(containerID);

  LOG.info("Getting container-status for " + containerIDStr);
  authorizeGetAndStopContainerRequest(containerID, container, false,
    nmTokenIdentifier);

  if (container == null) {
    if (nodeStatusUpdater.isContainerRecentlyStopped(containerID)) {
      throw RPCUtil.getRemoteException("Container " + containerIDStr
        + " was recently stopped on node manager.");
    } else {
      throw RPCUtil.getRemoteException("Container " + containerIDStr
        + " is not handled by this NodeManager");
    }
  }
  ContainerStatus containerStatus = container.cloneAndGetContainerStatus();
  LOG.info("Returning " + containerStatus);
  return containerStatus;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:ContainerManagerImpl.java

示例4: renewDelegationToken

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public RenewDelegationTokenResponse renewDelegationToken(
    RenewDelegationTokenRequest request) throws YarnException {
  try {
    if (!isAllowedDelegationTokenOp()) {
      throw new IOException(
          "Delegation Token can be renewed only with kerberos authentication");
    }
    
    org.apache.hadoop.yarn.api.records.Token protoToken = request.getDelegationToken();
    Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(
        protoToken.getIdentifier().array(), protoToken.getPassword().array(),
        new Text(protoToken.getKind()), new Text(protoToken.getService()));

    String user = getRenewerForToken(token);
    long nextExpTime = rmDTSecretManager.renewToken(token, user);
    RenewDelegationTokenResponse renewResponse = Records
        .newRecord(RenewDelegationTokenResponse.class);
    renewResponse.setNextExpirationTime(nextExpTime);
    return renewResponse;
  } catch (IOException e) {
    throw RPCUtil.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:ClientRMService.java

示例5: cancelDelegationToken

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public CancelDelegationTokenResponse cancelDelegationToken(
    CancelDelegationTokenRequest request) throws YarnException {
  try {
    if (!isAllowedDelegationTokenOp()) {
      throw new IOException(
          "Delegation Token can be cancelled only with kerberos authentication");
    }
    org.apache.hadoop.yarn.api.records.Token protoToken = request.getDelegationToken();
    Token<RMDelegationTokenIdentifier> token = new Token<RMDelegationTokenIdentifier>(
        protoToken.getIdentifier().array(), protoToken.getPassword().array(),
        new Text(protoToken.getKind()), new Text(protoToken.getService()));

    String user = UserGroupInformation.getCurrentUser().getUserName();
    rmDTSecretManager.cancelToken(token, user);
    return Records.newRecord(CancelDelegationTokenResponse.class);
  } catch (IOException e) {
    throw RPCUtil.getRemoteException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:ClientRMService.java

示例6: checkReservationACLs

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
private String checkReservationACLs(String queueName, String auditConstant)
    throws YarnException {
  UserGroupInformation callerUGI;
  try {
    callerUGI = UserGroupInformation.getCurrentUser();
  } catch (IOException ie) {
    RMAuditLogger.logFailure("UNKNOWN", auditConstant, queueName,
        "ClientRMService", "Error getting UGI");
    throw RPCUtil.getRemoteException(ie);
  }
  // Check if user has access on the managed queue
  if (!queueACLsManager.checkAccess(callerUGI, QueueACL.SUBMIT_APPLICATIONS,
      queueName)) {
    RMAuditLogger.logFailure(
        callerUGI.getShortUserName(),
        auditConstant,
        "User doesn't have permissions to "
            + QueueACL.SUBMIT_APPLICATIONS.toString(), "ClientRMService",
        AuditConstants.UNAUTHORIZED_USER);
    throw RPCUtil.getRemoteException(new AccessControlException("User "
        + callerUGI.getShortUserName() + " cannot perform operation "
        + QueueACL.SUBMIT_APPLICATIONS.name() + " on queue" + queueName));
  }
  return callerUGI.getShortUserName();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:ClientRMService.java

示例7: startContainerAsync

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
public void startContainerAsync(
    Container container, ContainerLaunchContext containerLaunchContext) {
  if (containers.putIfAbsent(container.getId(),
      new StatefulContainer(this, container.getId())) != null) {
    callbackHandler.onStartContainerError(container.getId(),
        RPCUtil.getRemoteException("Container " + container.getId() +
            " is already started or scheduled to start"));
  }
  try {
    events.put(new StartContainerEvent(container, containerLaunchContext));
  } catch (InterruptedException e) {
    LOG.warn("Exception when scheduling the event of starting Container " +
        container.getId());
    callbackHandler.onStartContainerError(container.getId(), e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:NMClientAsyncImpl.java

示例8: stopContainers

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
/**
 * Stop a list of containers running on this NodeManager.
 */
@Override
public StopContainersResponse stopContainers(StopContainersRequest requests)
    throws YarnException, IOException {

  List<ContainerId> succeededRequests = new ArrayList<ContainerId>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  if (identifier == null) {
    throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
  }
  for (ContainerId id : requests.getContainerIds()) {
    try {
      stopContainerInternal(identifier, id);
      succeededRequests.add(id);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return StopContainersResponse
    .newInstance(succeededRequests, failedRequests);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:ContainerManagerImpl.java

示例9: getContainerStatuses

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
/**
 * Get a list of container statuses running on this NodeManager
 */
@Override
public GetContainerStatusesResponse getContainerStatuses(
    GetContainerStatusesRequest request) throws YarnException, IOException {

  List<ContainerStatus> succeededRequests = new ArrayList<ContainerStatus>();
  Map<ContainerId, SerializedException> failedRequests =
      new HashMap<ContainerId, SerializedException>();
  UserGroupInformation remoteUgi = getRemoteUgi();
  NMTokenIdentifier identifier = selectNMTokenIdentifier(remoteUgi);
  if (identifier == null) {
    throw RPCUtil.getRemoteException(INVALID_NMTOKEN_MSG);
  }
  for (ContainerId id : request.getContainerIds()) {
    try {
      ContainerStatus status = getContainerStatusInternal(id, identifier);
      succeededRequests.add(status);
    } catch (YarnException e) {
      failedRequests.put(id, SerializedException.newInstance(e));
    }
  }
  return GetContainerStatusesResponse.newInstance(succeededRequests,
    failedRequests);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:ContainerManagerImpl.java

示例10: increaseContainerResourceAsync

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
public void increaseContainerResourceAsync(Container container) {
  if (!(callbackHandler instanceof AbstractCallbackHandler)) {
    LOG.error("Callback handler does not implement container resource "
            + "increase callback methods");
    return;
  }
  AbstractCallbackHandler handler = (AbstractCallbackHandler) callbackHandler;
  if (containers.get(container.getId()) == null) {
    handler.onIncreaseContainerResourceError(
        container.getId(),
        RPCUtil.getRemoteException(
            "Container " + container.getId() +
                " is neither started nor scheduled to start"));
  }
  try {
    events.put(new IncreaseContainerResourceEvent(container));
  } catch (InterruptedException e) {
    LOG.warn("Exception when scheduling the event of increasing resource of "
        + "Container " + container.getId());
    handler.onIncreaseContainerResourceError(container.getId(), e);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:23,代码来源:NMClientAsyncImpl.java

示例11: getClusterSpec

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public GetClusterSpecResponse getClusterSpec(GetClusterSpecRequest request) throws YarnException, IOException {
  GetClusterSpecRequestProto requestProto = ((GetClusterSpecRequestPBImpl) request).getProto();
  try {
    return new GetClusterSpecResponsePBImpl(proxy.getClusterSpec(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
开发者ID:Intel-bigdata,项目名称:TensorFlowOnYARN,代码行数:11,代码来源:TensorFlowClusterPBClientImpl.java

示例12: allocate

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public AllocateResponse allocate(AllocateRequest request)
    throws YarnException, IOException {
  AllocateRequestProto requestProto =
      ((AllocateRequestPBImpl) request).getProto();
  try {
    return new AllocateResponsePBImpl(proxy.allocate(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:ApplicationMasterProtocolPBClientImpl.java

示例13: finishApplicationMaster

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public FinishApplicationMasterResponse finishApplicationMaster(
    FinishApplicationMasterRequest request) throws YarnException,
    IOException {
  FinishApplicationMasterRequestProto requestProto =
      ((FinishApplicationMasterRequestPBImpl) request).getProto();
  try {
    return new FinishApplicationMasterResponsePBImpl(
      proxy.finishApplicationMaster(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:ApplicationMasterProtocolPBClientImpl.java

示例14: registerApplicationMaster

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public RegisterApplicationMasterResponse registerApplicationMaster(
    RegisterApplicationMasterRequest request) throws YarnException,
    IOException {
  RegisterApplicationMasterRequestProto requestProto =
      ((RegisterApplicationMasterRequestPBImpl) request).getProto();
  try {
    return new RegisterApplicationMasterResponsePBImpl(
      proxy.registerApplicationMaster(null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:ApplicationMasterProtocolPBClientImpl.java

示例15: getApplicationReport

import org.apache.hadoop.yarn.ipc.RPCUtil; //导入依赖的package包/类
@Override
public GetApplicationReportResponse getApplicationReport(
    GetApplicationReportRequest request) throws YarnException, IOException {
  GetApplicationReportRequestProto requestProto =
      ((GetApplicationReportRequestPBImpl) request).getProto();
  try {
    return new GetApplicationReportResponsePBImpl(proxy.getApplicationReport(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:ApplicationHistoryProtocolPBClientImpl.java


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