@Override
    public void configure(YarnAppmasterConfigurer master) throws Exception {
      master
          .appmasterClass(
              syap.getAppmasterClass() != null ? syap.getAppmasterClass() : appmasterClass)
          .containerCommands(createContainerCommands(syalcp));

      MasterContainerAllocatorConfigurer containerAllocatorConfigurer =
          master.withContainerAllocator();
      containerAllocatorConfigurer
          .locality(syalcp.isLocality())
          .memory(syarp.getMemory())
          .priority(syarp.getPriority())
          .virtualCores(syarp.getVirtualCores());

      if (syap.getContainercluster() != null && syap.getContainercluster().getClusters() != null) {
        for (java.util.Map.Entry<String, ContainerClustersProperties> entry :
            syap.getContainercluster().getClusters().entrySet()) {
          SpringYarnAppmasterResourceProperties resource = entry.getValue().getResource();
          SpringYarnAppmasterLaunchContextProperties launchcontext =
              entry.getValue().getLaunchcontext();

          master.containerCommands(entry.getKey(), createContainerCommands(launchcontext));

          containerAllocatorConfigurer
              .withCollection(entry.getKey())
              .priority(resource != null ? resource.getPriority() : null)
              .memory(resource != null ? resource.getMemory() : null)
              .virtualCores(resource != null ? resource.getVirtualCores() : null)
              .locality(launchcontext != null ? launchcontext.isLocality() : false);
        }
      }
    }
  private static String[] createContainerCommands(SpringYarnAppmasterLaunchContextProperties syalcp)
      throws Exception {
    LaunchCommandsFactoryBean factory = new LaunchCommandsFactoryBean();
    String containerJar = syalcp.getArchiveFile();

    if (StringUtils.hasText(containerJar) && containerJar.endsWith("jar")) {
      factory.setJarFile(containerJar);
    } else if (StringUtils.hasText(syalcp.getRunnerClass())) {
      factory.setRunnerClass(syalcp.getRunnerClass());
    } else if (StringUtils.hasText(containerJar) && containerJar.endsWith("zip")) {
      factory.setRunnerClass("org.springframework.boot.loader.PropertiesLauncher");
    }

    factory.setArgumentsList(syalcp.getArgumentsList());

    if (syalcp.getArguments() != null) {
      Properties arguments = new Properties();
      arguments.putAll(syalcp.getArguments());
      factory.setArguments(arguments);
    }

    factory.setOptions(syalcp.getOptions());

    factory.setStdout("<LOG_DIR>/Container.stdout");
    factory.setStderr("<LOG_DIR>/Container.stderr");
    factory.afterPropertiesSet();
    return factory.getObject();
  }
 private static String explodedEntryIfZip(SpringYarnAppmasterLaunchContextProperties syalcp) {
   return StringUtils.endsWithIgnoreCase(syalcp.getArchiveFile(), ".zip")
       ? "./" + syalcp.getArchiveFile()
       : null;
 }
    @Override
    public void configure(YarnEnvironmentConfigurer environment) throws Exception {
      environment
          .includeLocalSystemEnv(syalcp.isIncludeLocalSystemEnv())
          .withClasspath()
          .includeBaseDirectory(syalcp.isIncludeBaseDirectory())
          .useYarnAppClasspath(syalcp.isUseYarnAppClasspath())
          .useMapreduceAppClasspath(syalcp.isUseMapreduceAppClasspath())
          .siteYarnAppClasspath(syp.getSiteYarnAppClasspath())
          .siteMapreduceAppClasspath(syp.getSiteMapreduceAppClasspath())
          .delimiter(syalcp.getPathSeparator())
          .entries(syalcp.getContainerAppClasspath())
          .entry(explodedEntryIfZip(syalcp));

      if (syap.getContainercluster() != null && syap.getContainercluster().getClusters() != null) {
        for (java.util.Map.Entry<String, ContainerClustersProperties> entry :
            syap.getContainercluster().getClusters().entrySet()) {
          SpringYarnAppmasterLaunchContextProperties props = entry.getValue().getLaunchcontext();
          environment
              .withClasspath(entry.getKey())
              .includeBaseDirectory(props.isIncludeBaseDirectory())
              .useYarnAppClasspath(props.isUseYarnAppClasspath())
              .useMapreduceAppClasspath(props.isUseMapreduceAppClasspath())
              .siteYarnAppClasspath(syp.getSiteYarnAppClasspath())
              .siteMapreduceAppClasspath(syp.getSiteMapreduceAppClasspath())
              .delimiter(props.getPathSeparator())
              .entries(props.getContainerAppClasspath())
              .entry(explodedEntryIfZip(props));
        }
      }
    }