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


Java ApplicationSubmissionContext.setMaxAppAttempts方法代碼示例

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


在下文中一共展示了ApplicationSubmissionContext.setMaxAppAttempts方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newApplicationSubmissionContext

import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; //導入方法依賴的package包/類
public static ApplicationSubmissionContext newApplicationSubmissionContext(
    ApplicationId applicationId, String applicationName, String queue,
    Priority priority, ContainerLaunchContext amContainer,
    boolean isUnmanagedAM, boolean cancelTokensWhenComplete,
    int maxAppAttempts, Resource resource, String applicationType) {
  ApplicationSubmissionContext context =
      recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
  context.setApplicationId(applicationId);
  context.setApplicationName(applicationName);
  context.setQueue(queue);
  context.setPriority(priority);
  context.setAMContainerSpec(amContainer);
  context.setUnmanagedAM(isUnmanagedAM);
  context.setCancelTokensWhenComplete(cancelTokensWhenComplete);
  context.setMaxAppAttempts(maxAppAttempts);
  context.setResource(resource);
  context.setApplicationType(applicationType);
  return context;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:BuilderUtils.java

示例2: startAppMaster

import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; //導入方法依賴的package包/類
private ApplicationReport startAppMaster(ApplicationSubmissionContext appContext) throws Exception {
  appContext.setMaxAppAttempts(MAX_ATTEMPT);

  Map<String, LocalResource> localResources = new HashMap<>();
  Set<Path> shippedPaths = new HashSet<>();
  collectLocalResources(localResources, shippedPaths);
  final ContainerLaunchContext amContainer = setupApplicationMasterContainer(false, true, false);

  amContainer.setLocalResources(localResources);

  final String classPath = localResources.keySet().stream().collect(Collectors.joining(File.pathSeparator));
  final String shippedFiles = shippedPaths.stream().map(Path::toString)
      .collect(Collectors.joining(","));

  // Setup CLASSPATH and environment variables for ApplicationMaster
  ApplicationId appId = appContext.getApplicationId();
  final Map<String, String> appMasterEnv = setUpAmEnvironment(
      appId,
      classPath,
      shippedFiles,
      getDynamicPropertiesEncoded()
  );

  amContainer.setEnvironment(appMasterEnv);

  // Set up resource type requirements for ApplicationMaster
  Resource capability = Records.newRecord(Resource.class);
  capability.setMemory(getFlinkConfiguration()
      .getInteger(JobManagerOptions.JOB_MANAGER_HEAP_MEMORY));
  capability.setVirtualCores(1);

  appContext.setApplicationName(job.name());
  appContext.setApplicationType(ATHENAX_APPLICATION_TYPE);
  appContext.setAMContainerSpec(amContainer);
  appContext.setResource(capability);
  appContext.setApplicationTags(Collections.singleton(job.metadata().serialize()));
  if (job.queue() != null) {
    appContext.setQueue(job.queue());
  }

  LOG.info("Submitting application master {}", appId);
  yarnClient.submitApplication(appContext);

  PollDeploymentStatus poll = new PollDeploymentStatus(appId);
  YARN_POLL_EXECUTOR.submit(poll);
  try {
    return poll.result.get();
  } catch (ExecutionException e) {
    LOG.warn("Failed to deploy {}, cause: {}", appId.toString(), e.getCause());
    yarnClient.killApplication(appId);
    throw (Exception) e.getCause();
  }
}
 
開發者ID:uber,項目名稱:AthenaX,代碼行數:54,代碼來源:AthenaXYarnClusterDescriptor.java

示例3: submitApp

import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; //導入方法依賴的package包/類
private void submitApp()
        throws YarnException, InterruptedException, IOException {
  // ask for new application
  GetNewApplicationRequest newAppRequest =
      Records.newRecord(GetNewApplicationRequest.class);
  GetNewApplicationResponse newAppResponse = 
      rm.getClientRMService().getNewApplication(newAppRequest);
  appId = newAppResponse.getApplicationId();
  
  // submit the application
  final SubmitApplicationRequest subAppRequest =
      Records.newRecord(SubmitApplicationRequest.class);
  ApplicationSubmissionContext appSubContext = 
      Records.newRecord(ApplicationSubmissionContext.class);
  appSubContext.setApplicationId(appId);
  appSubContext.setMaxAppAttempts(1);
  appSubContext.setQueue(queue);
  appSubContext.setPriority(Priority.newInstance(0));
  ContainerLaunchContext conLauContext = 
      Records.newRecord(ContainerLaunchContext.class);
  conLauContext.setApplicationACLs(
      new HashMap<ApplicationAccessType, String>());
  conLauContext.setCommands(new ArrayList<String>());
  conLauContext.setEnvironment(new HashMap<String, String>());
  conLauContext.setLocalResources(new HashMap<String, LocalResource>());
  conLauContext.setServiceData(new HashMap<String, ByteBuffer>());
  appSubContext.setAMContainerSpec(conLauContext);
  appSubContext.setUnmanagedAM(true);
  subAppRequest.setApplicationSubmissionContext(appSubContext);
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser(user);
  ugi.doAs(new PrivilegedExceptionAction<Object>() {
    @Override
    public Object run() throws YarnException {
      rm.getClientRMService().submitApplication(subAppRequest);
      return null;
    }
  });
  LOG.info(MessageFormat.format("Submit a new application {0}", appId));
  
  // waiting until application ACCEPTED
  RMApp app = rm.getRMContext().getRMApps().get(appId);
  while(app.getState() != RMAppState.ACCEPTED) {
    Thread.sleep(10);
  }

  // Waiting until application attempt reach LAUNCHED
  // "Unmanaged AM must register after AM attempt reaches LAUNCHED state"
  this.appAttemptId = rm.getRMContext().getRMApps().get(appId)
      .getCurrentAppAttempt().getAppAttemptId();
  RMAppAttempt rmAppAttempt = rm.getRMContext().getRMApps().get(appId)
      .getCurrentAppAttempt();
  while (rmAppAttempt.getAppAttemptState() != RMAppAttemptState.LAUNCHED) {
    Thread.sleep(10);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:56,代碼來源:AMSimulator.java

示例4: main

import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; //導入方法依賴的package包/類
/**
 * Submits an application to Yarn,
 *
 * @param args
 *          the program arguments
 * @throws IOException
 *           if an error occurs
 * @throws YarnException
 *           if an error occurs
 */
public static void main(String[] args) throws IOException, YarnException {
  if (args.length <= 0) {
    System.err.println(
        "Usage: yarn " + Launcher.class.getCanonicalName() + " COMMAND");
    System.exit(1);
  }
  final List<String> command = new ArrayList<String>();
  command.add(args[0]);
  command.add("-D" + apgas.impl.Config.APGAS_LAUNCHER + "="
      + Launcher.class.getCanonicalName());
  command.add("-D" + apgas.impl.Config.APGAS_JAVA + "=" + args[0]);
  String classpath = "";
  for (int i = 1; i < args.length; i++) {
    if (args[i].equals("-cp") || args[i].equals("-classpath")) {
      classpath = args[++i];
    } else {
      command.add(args[i]);
    }
  }
  redirect(command);
  final Configuration conf = new YarnConfiguration();
  final YarnClient yarnClient = YarnClient.createYarnClient();
  yarnClient.init(conf);
  yarnClient.start();
  final String cp = String.join(ApplicationConstants.CLASS_PATH_SEPARATOR,
      conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
          YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH));
  final Map<String, String> env = Collections.singletonMap(
      Environment.CLASSPATH.name(),
      classpath + ApplicationConstants.CLASS_PATH_SEPARATOR + cp);
  final ContainerLaunchContext ctx = ContainerLaunchContext.newInstance(null,
      env, command, null, null, null);
  final ApplicationSubmissionContext appContext = yarnClient
      .createApplication().getApplicationSubmissionContext();
  appContext.setAMContainerSpec(ctx);
  appContext.setResource(Resource.newInstance(256, 1));
  appContext.setMaxAppAttempts(1);
  final ApplicationId appId = appContext.getApplicationId();
  yarnClient.submitApplication(appContext);
  YarnApplicationState appState;
  for (;;) {
    appState = yarnClient.getApplicationReport(appId)
        .getYarnApplicationState();
    if (appState == YarnApplicationState.FINISHED
        || appState == YarnApplicationState.KILLED
        || appState == YarnApplicationState.FAILED) {
      break;
    }
    try {
      Thread.sleep(100);
    } catch (final InterruptedException e) {
    }
  }
  System.err.println(appId + " finished with state " + appState);
}
 
開發者ID:x10-lang,項目名稱:apgas,代碼行數:66,代碼來源:Launcher.java


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