當前位置: 首頁>>代碼示例>>Java>>正文


Java ApplicationAttemptId類代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.api.records.ApplicationAttemptId的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationAttemptId類的具體用法?Java ApplicationAttemptId怎麽用?Java ApplicationAttemptId使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ApplicationAttemptId類屬於org.apache.hadoop.yarn.api.records包,在下文中一共展示了ApplicationAttemptId類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: allocate

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
private void allocate(LocalRMEvent event) throws IOException, InvalidParameterException {
  ApplicationId appId = event.getAppId();
  int attemptIndex;
  if(appIdToAttemptIndexMap.containsKey(appId)) {
    attemptIndex = appIdToAttemptIndexMap.get(appId);     
  } else {
    attemptIndex = 1;
  }
  
  appIdToAttemptIndexMap.put(appId, attemptIndex + 1);
  
  if(attemptIndex > maxAttemptNum) {
    return;
  }
  LocalClusterContext.get().setMaster(null);
  stopWorkerAndPS();
  
  LocalMaster master = new LocalMaster(ApplicationAttemptId.newInstance(appId, attemptIndex));
  master.start();
  LocalClusterContext.get().setMaster(master);
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:22,代碼來源:LocalResourceManager.java

示例2: Application

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
public Application(String user, String queue, ResourceManager resourceManager) 
    throws YarnException {
  this.user = user;
  this.queue = queue;
  this.resourceManager = resourceManager;
  // register an application
  GetNewApplicationRequest request =
          Records.newRecord(GetNewApplicationRequest.class);
  GetNewApplicationResponse newApp = 
      this.resourceManager.getClientRMService().getNewApplication(request);
  this.applicationId = newApp.getApplicationId();

  this.applicationAttemptId =
      ApplicationAttemptId.newInstance(this.applicationId,
        this.numAttempts.getAndIncrement());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:Application.java

示例3: testGetContainerReport

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test
public void testGetContainerReport() throws YarnException, IOException {
  ClientRMService rmService = createRMService();
  RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
  GetContainerReportRequest request = recordFactory
      .newRecordInstance(GetContainerReportRequest.class);
  ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(123456, 1), 1);
  ContainerId containerId = ContainerId.newContainerId(attemptId, 1);
  request.setContainerId(containerId);

  try {
    GetContainerReportResponse response = rmService
        .getContainerReport(request);
    Assert.assertEquals(containerId, response.getContainerReport()
        .getContainerId());
  } catch (ApplicationNotFoundException ex) {
    Assert.fail(ex.getMessage());
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestClientRMService.java

示例4: testMassiveWriteContainerHistory

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test
public void testMassiveWriteContainerHistory() throws IOException {
  long mb = 1024 * 1024;
  Runtime runtime = Runtime.getRuntime();
  long usedMemoryBefore = (runtime.totalMemory() - runtime.freeMemory()) / mb;
  int numContainers = 100000;
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  for (int i = 1; i <= numContainers; ++i) {
    ContainerId containerId = ContainerId.newContainerId(appAttemptId, i);
    writeContainerStartData(containerId);
    writeContainerFinishData(containerId);
  }
  long usedMemoryAfter = (runtime.totalMemory() - runtime.freeMemory()) / mb;
  Assert.assertTrue((usedMemoryAfter - usedMemoryBefore) < 400);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:TestMemoryApplicationHistoryStore.java

示例5: modifyAppState

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Override
protected void modifyAppState() throws Exception {
  // imitate appAttemptFile1 is still .new, but old one is deleted
  String appAttemptIdStr1 = "appattempt_1352994193343_0001_000001";
  ApplicationAttemptId attemptId1 =
      ConverterUtils.toApplicationAttemptId(appAttemptIdStr1);
  Path appDir =
          fsTester.store.getAppDir(attemptId1.getApplicationId().toString());
  Path appAttemptFile1 =
      new Path(appDir, attemptId1.toString() + ".new");
  FileSystemRMStateStore fileSystemRMStateStore =
      (FileSystemRMStateStore) fsTester.getRMStateStore();
  fileSystemRMStateStore.renameFile(appAttemptFile1,
          new Path(appAttemptFile1.getParent(),
                  appAttemptFile1.getName() + ".new"));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TestFSRMStateStore.java

示例6: testGetApplicationAttempt

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test(timeout = 10000)
public void testGetApplicationAttempt() 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);
  ApplicationAttemptReport report =
      client.getApplicationAttemptReport(appAttemptId);
  Assert.assertNotNull(report);
  Assert.assertEquals(report.getApplicationAttemptId().toString(),
    expectedReports.get(0).getCurrentApplicationAttemptId().toString());
  client.stop();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestAHSClient.java

示例7: testPreemptionVariablesForQueueCreatedRuntime

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test
public void testPreemptionVariablesForQueueCreatedRuntime() throws Exception {
  conf.set(FairSchedulerConfiguration.USER_AS_DEFAULT_QUEUE, "true");
  scheduler.init(conf);
  scheduler.start();
  scheduler.reinitialize(conf, resourceManager.getRMContext());

  // Set preemption variables for the root queue
  FSParentQueue root = scheduler.getQueueManager().getRootQueue();
  root.setMinSharePreemptionTimeout(10000);
  root.setFairSharePreemptionTimeout(15000);
  root.setFairSharePreemptionThreshold(.6f);

  // User1 submits one application
  ApplicationAttemptId appAttemptId = createAppAttemptId(1, 1);
  createApplicationWithAMResource(appAttemptId, "default", "user1", null);

  // The user1 queue should inherit the configurations from the root queue
  FSLeafQueue userQueue =
      scheduler.getQueueManager().getLeafQueue("user1", true);
  assertEquals(1, userQueue.getNumRunnableApps());
  assertEquals(10000, userQueue.getMinSharePreemptionTimeout());
  assertEquals(15000, userQueue.getFairSharePreemptionTimeout());
  assertEquals(.6f, userQueue.getFairSharePreemptionThreshold(), 0.001);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:TestFairScheduler.java

示例8: testAMRMTokenIdentifier

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test
public void testAMRMTokenIdentifier() throws IOException {
  ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
      ApplicationId.newInstance(1, 1), 1);
  int masterKeyId = 1;

  AMRMTokenIdentifier token = new AMRMTokenIdentifier(appAttemptId, masterKeyId);
  
  AMRMTokenIdentifier anotherToken = new AMRMTokenIdentifier();
  byte[] tokenContent = token.getBytes();
  DataInputBuffer dib = new DataInputBuffer();
  dib.reset(tokenContent, tokenContent.length);
  anotherToken.readFields(dib);
      
  // verify the whole record equals with original record
  Assert.assertEquals("Token is not the same after serialization " +
      "and deserialization.", token, anotherToken);
      
  Assert.assertEquals("ApplicationAttemptId from proto is not the same with original token",
      anotherToken.getApplicationAttemptId(), appAttemptId);
  
  Assert.assertEquals("masterKeyId from proto is not the same with original token",
      anotherToken.getKeyId(), masterKeyId);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:TestYARNTokenIdentifier.java

示例9: testContainers

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test
public void testContainers() throws IOException, YarnException {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1);
  ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 2);
  GetContainersRequest request =
      GetContainersRequest.newInstance(appAttemptId);
  GetContainersResponse response =
      clientService.getContainers(request);
  List<ContainerReport> containers = response.getContainerList();
  Assert.assertNotNull(containers);
  Assert.assertEquals(containerId, containers.get(0).getContainerId());
  Assert.assertEquals(containerId1, containers.get(1).getContainerId());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:TestApplicationHistoryClientService.java

示例10: testGetContainers

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test(timeout = 10000)
public void testGetContainers() throws YarnException, IOException {
  Configuration conf = new Configuration();
  final AHSClient client = new MockAHSClient();
  client.init(conf);
  client.start();

  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(applicationId, 1);
  List<ContainerReport> reports = client.getContainers(appAttemptId);
  Assert.assertNotNull(reports);
  Assert.assertEquals(reports.get(0).getContainerId(),
    (ContainerId.newContainerId(appAttemptId, 1)));
  Assert.assertEquals(reports.get(1).getContainerId(),
    (ContainerId.newContainerId(appAttemptId, 2)));
  client.stop();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:TestAHSClient.java

示例11: testMultipleContainers

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Test
public void testMultipleContainers() throws Exception {
  ApplicationId appId = ApplicationId.newInstance(0, 1);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  WebResource r = resource();
  ClientResponse response =
      r.path("ws").path("v1").path("applicationhistory").path("apps")
        .path(appId.toString()).path("appattempts")
        .path(appAttemptId.toString()).path("containers")
        .queryParam("user.name", USERS[round])
        .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  if (round == 1) {
    assertEquals(
        Status.FORBIDDEN, response.getClientResponseStatus());
    return;
  }
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject containers = json.getJSONObject("containers");
  assertEquals("incorrect number of elements", 1, containers.length());
  JSONArray array = containers.getJSONArray("container");
  assertEquals("incorrect number of elements", 5, array.length());
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:26,代碼來源:TestAHSWebServices.java

示例12: getContainer

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
private ContainerReport getContainer(
    ContainerId containerId,
    HashMap<ApplicationAttemptId, List<ContainerReport>> containersToAppAttemptMapping)
    throws YarnException, IOException {
  List<ContainerReport> containersForAppAttempt =
      containersToAppAttemptMapping.get(containerId
          .getApplicationAttemptId());
  if (containersForAppAttempt == null) {
    throw new ApplicationNotFoundException(containerId
        .getApplicationAttemptId().getApplicationId() + " is not found ");
  }
  Iterator<ContainerReport> iterator = containersForAppAttempt.iterator();
  while (iterator.hasNext()) {
    ContainerReport next = iterator.next();
    if (next.getContainerId().equals(containerId)) {
      return next;
    }
  }
  throw new ContainerNotFoundException(containerId + " is not found ");
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestYarnClient.java

示例13: getApplicationAttemptReport

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Override
public ApplicationAttemptReport getApplicationAttemptReport(
    ApplicationAttemptId appAttemptId) throws YarnException, IOException {
  try {
    GetApplicationAttemptReportRequest request = Records
        .newRecord(GetApplicationAttemptReportRequest.class);
    request.setApplicationAttemptId(appAttemptId);
    GetApplicationAttemptReportResponse response = rmClient
        .getApplicationAttemptReport(request);
    return response.getApplicationAttemptReport();
  } 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.getApplicationAttemptReport(appAttemptId);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:YarnClientImpl.java

示例14: applicationAttemptStarted

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Override
public void applicationAttemptStarted(
    ApplicationAttemptStartData appAttemptStart) throws IOException {
  ConcurrentMap<ApplicationAttemptId, ApplicationAttemptHistoryData> subMap =
      getSubMap(appAttemptStart.getApplicationAttemptId().getApplicationId());
  ApplicationAttemptHistoryData oldData =
      subMap.putIfAbsent(appAttemptStart.getApplicationAttemptId(),
        ApplicationAttemptHistoryData.newInstance(
          appAttemptStart.getApplicationAttemptId(),
          appAttemptStart.getHost(), appAttemptStart.getRPCPort(),
          appAttemptStart.getMasterContainerId(), null, null, null, null));
  if (oldData != null) {
    throw new IOException("The start information of application attempt "
        + appAttemptStart.getApplicationAttemptId() + " is already stored.");
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:17,代碼來源:MemoryApplicationHistoryStore.java

示例15: updateApplicationAttemptStateInternal

import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; //導入依賴的package包/類
@Override
public synchronized void updateApplicationAttemptStateInternal(
    ApplicationAttemptId appAttemptId,
    ApplicationAttemptStateData attemptStateDataPB)
    throws Exception {
  String appIdStr = appAttemptId.getApplicationId().toString();
  String appAttemptIdStr = appAttemptId.toString();
  String appDirPath = getNodePath(rmAppRoot, appIdStr);
  String nodeUpdatePath = getNodePath(appDirPath, appAttemptIdStr);
  if (LOG.isDebugEnabled()) {
    LOG.debug("Storing final state info for attempt: " + appAttemptIdStr
        + " at: " + nodeUpdatePath);
  }
  byte[] attemptStateData = attemptStateDataPB.getProto().toByteArray();

  if (existsWithRetries(nodeUpdatePath, false) != null) {
    setDataWithRetries(nodeUpdatePath, attemptStateData, -1);
  } else {
    createWithRetries(nodeUpdatePath, attemptStateData, zkAcl,
      CreateMode.PERSISTENT);
    LOG.debug(appAttemptId + " znode didn't exist. Created a new znode to"
        + " update the application attempt state.");
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:ZKRMStateStore.java


注:本文中的org.apache.hadoop.yarn.api.records.ApplicationAttemptId類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。