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

Java YarnException类代码示例

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

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



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

示例1: registerNodeManager

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Override
public RegisterNodeManagerResponse registerNodeManager(
    RegisterNodeManagerRequest request) throws YarnException,
    IOException {
  RegisterNodeManagerResponse response = recordFactory
      .newRecordInstance(RegisterNodeManagerResponse.class);
  MasterKey masterKey = new MasterKeyPBImpl();
  masterKey.setKeyId(123);
  masterKey.setBytes(ByteBuffer.wrap(new byte[] { new Integer(123)
    .byteValue() }));
  response.setContainerTokenMasterKey(masterKey);
  response.setNMTokenMasterKey(masterKey);
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:MockNodeStatusUpdater.java


示例2: listClusterNodes

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
/**
 * Lists the nodes matching the given node states
 * 
 * @param nodeStates
 * @throws YarnException
 * @throws IOException
 */
private void listClusterNodes(Set<NodeState> nodeStates) 
          throws YarnException, IOException {
  PrintWriter writer = new PrintWriter(
      new OutputStreamWriter(sysout, Charset.forName("UTF-8")));
  List<NodeReport> nodesReport = client.getNodeReports(
                                     nodeStates.toArray(new NodeState[0]));
  writer.println("Total Nodes:" + nodesReport.size());
  writer.printf(NODES_PATTERN, "Node-Id", "Node-State", "Node-Http-Address",
      "Number-of-Running-Containers");
  for (NodeReport nodeReport : nodesReport) {
    writer.printf(NODES_PATTERN, nodeReport.getNodeId(), nodeReport
        .getNodeState(), nodeReport.getHttpAddress(), nodeReport
        .getNumContainers());
  }
  writer.flush();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:NodeCLI.java


示例3: testCorruptedOwnerInfoForEntity

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Test
public void testCorruptedOwnerInfoForEntity() throws Exception {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
  conf.set(YarnConfiguration.YARN_ADMIN_ACL, "owner");
  TimelineACLsManager timelineACLsManager =
      new TimelineACLsManager(conf);
  timelineACLsManager.setTimelineStore(new TestTimelineStore());
  TimelineEntity entity = new TimelineEntity();
  try {
    timelineACLsManager.checkAccess(
        UserGroupInformation.createRemoteUser("owner"),
        ApplicationAccessType.VIEW_APP, entity);
    Assert.fail("Exception is expected");
  } catch (YarnException e) {
    Assert.assertTrue("It's not the exact expected exception", e.getMessage()
        .contains("doesn't exist."));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestTimelineACLsManager.java


示例4: startAM

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void startAM() throws YarnException, IOException {
  // application/container configuration
  int heartbeatInterval = conf.getInt(
          SLSConfiguration.AM_HEARTBEAT_INTERVAL_MS,
          SLSConfiguration.AM_HEARTBEAT_INTERVAL_MS_DEFAULT);
  int containerMemoryMB = conf.getInt(SLSConfiguration.CONTAINER_MEMORY_MB,
          SLSConfiguration.CONTAINER_MEMORY_MB_DEFAULT);
  int containerVCores = conf.getInt(SLSConfiguration.CONTAINER_VCORES,
          SLSConfiguration.CONTAINER_VCORES_DEFAULT);
  Resource containerResource =
          BuilderUtils.newResource(containerMemoryMB, containerVCores);

  // application workload
  if (isSLS) {
    startAMFromSLSTraces(containerResource, heartbeatInterval);
  } else {
    startAMFromRumenTraces(containerResource, heartbeatInterval);
  }
  numAMs = amMap.size();
  remainingApps = numAMs;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:SLSRunner.java


示例5: getContainerStatuses

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的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);
  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:naver,项目名称:hadoop,代码行数:24,代码来源:ContainerManagerImpl.java


示例6: getApplicationAttempts

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Override
public List<ApplicationAttemptReport> getApplicationAttempts(
    ApplicationId appId) throws YarnException, IOException {
  try {
    GetApplicationAttemptsRequest request = Records
        .newRecord(GetApplicationAttemptsRequest.class);
    request.setApplicationId(appId);
    GetApplicationAttemptsResponse response = rmClient
        .getApplicationAttempts(request);
    return response.getApplicationAttemptList();
  } catch (YarnException e) {
    if (!historyServiceEnabled) {
      // Just throw it as usual if historyService is not enabled.
      throw e;
    }
    // Even if history-service is enabled, treat all exceptions still the same
    // except the following
    if (e.getClass() != ApplicationNotFoundException.class) {
      throw e;
    }
    return historyClient.getApplicationAttempts(appId);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:YarnClientImpl.java


示例7: cleanResourceReferences

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
/**
 * Clean all resource references to a cache resource that contain application
 * ids pointing to finished applications. If the resource key does not exist,
 * do nothing.
 *
 * @param key a unique identifier for a resource
 * @throws YarnException
 */
@Private
public void cleanResourceReferences(String key) throws YarnException {
  Collection<SharedCacheResourceReference> refs = getResourceReferences(key);
  if (!refs.isEmpty()) {
    Set<SharedCacheResourceReference> refsToRemove =
        new HashSet<SharedCacheResourceReference>();
    for (SharedCacheResourceReference r : refs) {
      if (!appChecker.isApplicationActive(r.getAppId())) {
        // application in resource reference is dead, it is safe to remove the
        // reference
        refsToRemove.add(r);
      }
    }
    if (refsToRemove.size() > 0) {
      removeResourceReferences(key, refsToRemove, false);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:SCMStore.java


示例8: testGetContainerReport

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Test(timeout = 10000)
public void testGetContainerReport() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  List<ApplicationReport> expectedReports =
      ((MockAHSClient) client).getReports();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  ContainerReport report = client.getContainerReport(containerId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getContainerId().toString(), (ContainerId
    .newContainerId(expectedReports.get(0).getCurrentApplicationAttemptId(), 1))
    .toString());
  client.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestAHSClient.java


示例9: testGetApplicationAttempts

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Test
public void testGetApplicationAttempts() throws YarnException, IOException {
  ClientRMService rmService = createRMService();
  RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
  GetApplicationAttemptsRequest request = recordFactory
      .newRecordInstance(GetApplicationAttemptsRequest.class);
  ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(123456, 1), 1);
  request.setApplicationId(ApplicationId.newInstance(123456, 1));

  try {
    GetApplicationAttemptsResponse response = rmService
        .getApplicationAttempts(request);
    Assert.assertEquals(1, response.getApplicationAttemptList().size());
    Assert.assertEquals(attemptId, response.getApplicationAttemptList()
        .get(0).getApplicationAttemptId());

  } catch (ApplicationNotFoundException ex) {
    Assert.fail(ex.getMessage());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestClientRMService.java


示例10: disableHostsFileReader

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
private void disableHostsFileReader(Exception ex) {
  LOG.warn("Failed to init hostsReader, disabling", ex);
  try {
    this.includesFile =
        conf.get(YarnConfiguration.DEFAULT_RM_NODES_INCLUDE_FILE_PATH);
    this.excludesFile =
        conf.get(YarnConfiguration.DEFAULT_RM_NODES_EXCLUDE_FILE_PATH);
    this.hostsReader =
        createHostsFileReader(this.includesFile, this.excludesFile);
    setDecomissionedNMsMetrics();
  } catch (IOException ioe2) {
    // Should *never* happen
    this.hostsReader = null;
    throw new YarnRuntimeException(ioe2);
  } catch (YarnException e) {
    // Should *never* happen
    this.hostsReader = null;
    throw new YarnRuntimeException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:NodesListManager.java


示例11: testGetContainerStatus

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
private void testGetContainerStatus(Container container, int index,
    ContainerState state, String diagnostics, List<Integer> exitStatuses)
        throws YarnException, IOException {
  while (true) {
    try {
      ContainerStatus status = nmClient.getContainerStatus(
          container.getId(), container.getNodeId());
      // NodeManager may still need some time to get the stable
      // container status
      if (status.getState() == state) {
        assertEquals(container.getId(), status.getContainerId());
        assertTrue("" + index + ": " + status.getDiagnostics(),
            status.getDiagnostics().contains(diagnostics));
        
        assertTrue("Exit Statuses are supposed to be in: " + exitStatuses +
            ", but the actual exit status code is: " + status.getExitStatus(),
            exitStatuses.contains(status.getExitStatus()));
        break;
      }
      Thread.sleep(100);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestNMClient.java


示例12: getConfiguration

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
private synchronized Configuration getConfiguration(Configuration conf,
    String... confFileNames) throws YarnException, IOException {
  for (String confFileName : confFileNames) {
    InputStream confFileInputStream = this.rmContext.getConfigurationProvider()
        .getConfigurationInputStream(conf, confFileName);
    if (confFileInputStream != null) {
      conf.addResource(confFileInputStream);
    }
  }
  return conf;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:AdminService.java


示例13: publishApplicationAttemptEvent

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
private static void publishApplicationAttemptEvent(
    final TimelineClient timelineClient, String appAttemptId,
    DSEvent appEvent, String domainId, UserGroupInformation ugi) {
  final TimelineEntity entity = new TimelineEntity();
  entity.setEntityId(appAttemptId);
  entity.setEntityType(DSEntity.DS_APP_ATTEMPT.toString());
  entity.setDomainId(domainId);
  entity.addPrimaryFilter("user", ugi.getShortUserName());
  TimelineEvent event = new TimelineEvent();
  event.setEventType(appEvent.toString());
  event.setTimestamp(System.currentTimeMillis());
  entity.addEvent(event);
  try {
    timelineClient.putEntities(entity);
  } catch (YarnException | IOException e) {
    LOG.error("App Attempt "
        + (appEvent.equals(DSEvent.DS_APP_ATTEMPT_START) ? "start" : "end")
        + " event could not be published for "
        + appAttemptId.toString(), e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ApplicationMaster.java


示例14: testNodeHeartbeat

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
/**
 * Test the method nodeHeartbeat. Method should return a not null result.
 * 
 */

@Test
public void testNodeHeartbeat() throws Exception {
  NodeHeartbeatRequest request = recordFactory
      .newRecordInstance(NodeHeartbeatRequest.class);
  assertNotNull(client.nodeHeartbeat(request));
  
  ResourceTrackerTestImpl.exception = true;
  try {
    client.nodeHeartbeat(request);
    fail("there  should be YarnException");
  } catch (YarnException e) {
    assertTrue(e.getMessage().startsWith("testMessage"));
  }finally{
    ResourceTrackerTestImpl.exception = false;
  }

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


示例15: listQueue

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
/**
 * Lists the Queue Information matching the given queue name
 * 
 * @param queueName
 * @throws YarnException
 * @throws IOException
 */
private int listQueue(String queueName) throws YarnException, IOException {
  int rc;
  PrintWriter writer = new PrintWriter(
      new OutputStreamWriter(sysout, Charset.forName("UTF-8")));

  QueueInfo queueInfo = client.getQueueInfo(queueName);
  if (queueInfo != null) {
    writer.println("Queue Information : ");
    printQueueInfo(writer, queueInfo);
    rc = 0;
  } else {
    writer.println("Cannot get queue from RM by queueName = " + queueName
        + ", please check.");
    rc = -1;
  }
  writer.flush();
  return rc;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:QueueCLI.java


示例16: refreshAdminAcls

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
private RefreshAdminAclsResponse refreshAdminAcls(boolean checkRMHAState)
    throws YarnException, IOException {
  String argName = "refreshAdminAcls";
  UserGroupInformation user = checkAcls(argName);

  if (checkRMHAState) {
    checkRMStatus(user.getShortUserName(), argName, "refresh Admin ACLs.");
  }
  Configuration conf =
      getConfiguration(new Configuration(false),
          YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
  authorizer.setAdmins(getAdminAclList(conf), UserGroupInformation
      .getCurrentUser());
  RMAuditLogger.logSuccess(user.getShortUserName(), argName,
      "AdminService");

  return recordFactory.newRecordInstance(RefreshAdminAclsResponse.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:AdminService.java


示例17: testApplicationReport

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Test
public void testApplicationReport() throws IOException, YarnException {
  ApplicationId appId = null;
  appId = ApplicationId.newInstance(0, 1);
  GetApplicationReportRequest request =
      GetApplicationReportRequest.newInstance(appId);
  GetApplicationReportResponse response =
      clientService.getApplicationReport(request);
  ApplicationReport appReport = response.getApplicationReport();
  Assert.assertNotNull(appReport);
  Assert.assertEquals(123, appReport.getApplicationResourceUsageReport()
      .getMemorySeconds());
  Assert.assertEquals(345, appReport.getApplicationResourceUsageReport()
      .getVcoreSeconds());
  Assert.assertEquals(345, appReport.getApplicationResourceUsageReport()
      .getGcoreSeconds());
  Assert.assertEquals("application_0_0001", appReport.getApplicationId()
    .toString());
  Assert.assertEquals("test app type",
      appReport.getApplicationType().toString());
  Assert.assertEquals("test queue", appReport.getQueue().toString());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestApplicationHistoryClientService.java


示例18: allocate

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Override
public AllocateResponse allocate(AllocateRequest request)
    throws YarnException, IOException {
  lastAsk = request.getAskList();
  for (ResourceRequest req : lastAsk) {
    if (ResourceRequest.ANY.equals(req.getResourceName())) {
      Priority priority = req.getPriority();
      if (priority.equals(RMContainerAllocator.PRIORITY_MAP)) {
        lastAnyAskMap = req.getNumContainers();
      } else if (priority.equals(RMContainerAllocator.PRIORITY_REDUCE)){
        lastAnyAskReduce = req.getNumContainers();
      }
    }
  }
  AllocateResponse response =  AllocateResponse.newInstance(
      request.getResponseId(),
      containersToComplete, containersToAllocate,
      Collections.<NodeReport>emptyList(),
      Resource.newInstance(512000, 1024, 1024), null, 10, null,
      Collections.<NMToken>emptyList());
  containersToComplete.clear();
  containersToAllocate.clear();
  return response;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestRMContainerAllocator.java


示例19: deSerialize

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Throwable deSerialize() {

  SerializedException cause = getCause();
  SerializedExceptionProtoOrBuilder p = viaProto ? proto : builder;
  Class<?> realClass = null;
  try {
    realClass = Class.forName(p.getClassName());
  } catch (ClassNotFoundException e) {
    throw new YarnRuntimeException(e);
  }
  Class classType = null;
  if (YarnException.class.isAssignableFrom(realClass)) {
    classType = YarnException.class;
  } else if (IOException.class.isAssignableFrom(realClass)) {
    classType = IOException.class;
  } else if (RuntimeException.class.isAssignableFrom(realClass)) {
    classType = RuntimeException.class;
  } else {
    classType = Exception.class;
  }
  return instantiateException(realClass.asSubclass(classType), getMessage(),
    cause == null ? null : cause.deSerialize());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:SerializedExceptionPBImpl.java


示例20: stopContainer

import org.apache.hadoop.yarn.exceptions.YarnException; //导入依赖的package包/类
@Override
public void stopContainer(ContainerId containerId, NodeId nodeId)
    throws YarnException, IOException {
  StartedContainer startedContainer = getStartedContainer(containerId);

  // Only allow one request of stopping the container to move forward
  // When entering the block, check whether the precursor has already stopped
  // the container
  if (startedContainer != null) {
    synchronized (startedContainer) {
      if (startedContainer.state != ContainerState.RUNNING) {
        return;
      }
      stopContainerInternal(containerId, nodeId);
      // Only after successful
      startedContainer.state = ContainerState.COMPLETE;
      removeStartedContainer(startedContainer);
    }
  } else {
    stopContainerInternal(containerId, nodeId);
  }

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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