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


Java ApplicationConstants類代碼示例

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


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

示例1: makeContainerCommand

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
private String makeContainerCommand(long containerMemory, String clusterSpec,
    String jobName, int taskIndex) {
  String[] commands = new String[]{
      ApplicationConstants.Environment.JAVA_HOME.$$() + "/bin/java",
      "-Xmx" + containerMemory + "m",
      TFServerRunner.class.getName() + " ",
      Utils.mkOption(Constants.OPT_CLUSTER_SPEC, clusterSpec),
      Utils.mkOption(Constants.OPT_JOB_NAME, jobName),
      Utils.mkOption(Constants.OPT_TASK_INDEX, taskIndex),
      "1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/TFServerRunner." +
          ApplicationConstants.STDOUT,
      "2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/TFServerRunner." +
          ApplicationConstants.STDERR
  };

  return Utils.mkString(commands, " ");
}
 
開發者ID:Intel-bigdata,項目名稱:TensorFlowOnYARN,代碼行數:18,代碼來源:LaunchContainerThread.java

示例2: makeAppMasterCommand

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
private String makeAppMasterCommand(String tfLib, String tfJar) {
  String[] commands = new String[]{
      ApplicationConstants.Environment.JAVA_HOME.$$() + "/bin/java",
      // Set Xmx based on am memory size
      "-Xmx" + amMemory + "m",
      // Set class name
      ApplicationMaster.class.getName(),
      Utils.mkOption(Constants.OPT_TF_CONTAINER_MEMORY, containerMemory),
      Utils.mkOption(Constants.OPT_TF_CONTAINER_VCORES, containerVCores),
      Utils.mkOption(Constants.OPT_TF_WORKER_NUM, workerNum),
      Utils.mkOption(Constants.OPT_TF_PS_NUM, psNum),
      Utils.mkOption(Constants.OPT_TF_LIB, tfLib),
      Utils.mkOption(Constants.OPT_TF_JAR, tfJar),
      "1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stdout",
      "2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stderr"
  };
  return Utils.mkString(commands, " ");
}
 
開發者ID:Intel-bigdata,項目名稱:TensorFlowOnYARN,代碼行數:19,代碼來源:LaunchCluster.java

示例3: setJavaEnv

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
public static Map<String, String> setJavaEnv(Configuration conf) {
  Map<String, String> env = new HashMap<>();

  StringBuilder classPathEnv = new StringBuilder(ApplicationConstants.Environment.CLASSPATH.$$())
      .append(ApplicationConstants.CLASS_PATH_SEPARATOR).append("./*");

  for (String c : conf.getStrings(
      YarnConfiguration.YARN_APPLICATION_CLASSPATH,
      YarnConfiguration.DEFAULT_YARN_CROSS_PLATFORM_APPLICATION_CLASSPATH)) {
    classPathEnv.append(ApplicationConstants.CLASS_PATH_SEPARATOR);
    classPathEnv.append(c.trim());
  }

  if (conf.getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER, false)) {
    classPathEnv.append(ApplicationConstants.CLASS_PATH_SEPARATOR);
    classPathEnv.append(System.getProperty("java.class.path"));
  }

  env.put("CLASSPATH", classPathEnv.toString());
  return env;
}
 
開發者ID:Intel-bigdata,項目名稱:TensorFlowOnYARN,代碼行數:22,代碼來源:Utils.java

示例4: expandEnvironment

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@VisibleForTesting
public static String expandEnvironment(String var,
    Path containerLogDir) {
  var = var.replace(ApplicationConstants.LOG_DIR_EXPANSION_VAR,
    containerLogDir.toString());
  var =  var.replace(ApplicationConstants.CLASS_PATH_SEPARATOR,
    File.pathSeparator);

  // replace parameter expansion marker. e.g. {{VAR}} on Windows is replaced
  // as %VAR% and on Linux replaced as "$VAR"
  if (Shell.WINDOWS) {
    var = var.replaceAll("(\\{\\{)|(\\}\\})", "%");
  } else {
    var = var.replace(ApplicationConstants.PARAMETER_EXPANSION_LEFT, "$");
    var = var.replace(ApplicationConstants.PARAMETER_EXPANSION_RIGHT, "");
  }
  return var;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:ContainerLaunch.java

示例5: testEnvExpansion

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@Test(timeout = 10000)
public void testEnvExpansion() throws IOException {
  Path logPath = new Path("/nm/container/logs");
  String input =
      Apps.crossPlatformify("HADOOP_HOME") + "/share/hadoop/common/*"
          + ApplicationConstants.CLASS_PATH_SEPARATOR
          + Apps.crossPlatformify("HADOOP_HOME") + "/share/hadoop/common/lib/*"
          + ApplicationConstants.CLASS_PATH_SEPARATOR
          + Apps.crossPlatformify("HADOOP_LOG_HOME")
          + ApplicationConstants.LOG_DIR_EXPANSION_VAR;

  String res = ContainerLaunch.expandEnvironment(input, logPath);

  if (Shell.WINDOWS) {
    Assert.assertEquals("%HADOOP_HOME%/share/hadoop/common/*;"
        + "%HADOOP_HOME%/share/hadoop/common/lib/*;"
        + "%HADOOP_LOG_HOME%/nm/container/logs", res);
  } else {
    Assert.assertEquals("$HADOOP_HOME/share/hadoop/common/*:"
        + "$HADOOP_HOME/share/hadoop/common/lib/*:"
        + "$HADOOP_LOG_HOME/nm/container/logs", res);
  }
  System.out.println(res);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:25,代碼來源:TestContainerLaunch.java

示例6: testSetClasspathWithUserPrecendence

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@Test (timeout = 120000)
public void testSetClasspathWithUserPrecendence() {
   Configuration conf = new Configuration();
   conf.setBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, true);
   conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, true);
   Map<String, String> env = new HashMap<String, String>();
   try {
     MRApps.setClasspath(env, conf);
   } catch (Exception e) {
     fail("Got exception while setting classpath");
   }
   String env_str = env.get("CLASSPATH");
   String expectedClasspath = StringUtils.join(ApplicationConstants.CLASS_PATH_SEPARATOR,
     Arrays.asList(ApplicationConstants.Environment.PWD.$$(), "job.jar/job.jar",
       "job.jar/classes/", "job.jar/lib/*",
       ApplicationConstants.Environment.PWD.$$() + "/*"));
   assertTrue("MAPREDUCE_JOB_USER_CLASSPATH_FIRST set, but not taking effect!",
     env_str.startsWith(expectedClasspath));
 }
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:TestMRApps.java

示例7: testSetClasspathWithNoUserPrecendence

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@Test (timeout = 120000)
public void testSetClasspathWithNoUserPrecendence() {
  Configuration conf = new Configuration();
  conf.setBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, true);
  conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_USER_CLASSPATH_FIRST, false);
  Map<String, String> env = new HashMap<String, String>();
  try {
    MRApps.setClasspath(env, conf);
  } catch (Exception e) {
    fail("Got exception while setting classpath");
  }
  String env_str = env.get("CLASSPATH");
  String expectedClasspath = StringUtils.join(ApplicationConstants.CLASS_PATH_SEPARATOR,
    Arrays.asList("job.jar/job.jar", "job.jar/classes/", "job.jar/lib/*",
      ApplicationConstants.Environment.PWD.$$() + "/*"));
  assertTrue("MAPREDUCE_JOB_USER_CLASSPATH_FIRST false, and job.jar is not in"
    + " the classpath!", env_str.contains(expectedClasspath));
  assertFalse("MAPREDUCE_JOB_USER_CLASSPATH_FIRST false, but taking effect!",
    env_str.startsWith(expectedClasspath));
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestMRApps.java

示例8: testSetClasspathWithJobClassloader

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@Test (timeout = 120000)
public void testSetClasspathWithJobClassloader() throws IOException {
  Configuration conf = new Configuration();
  conf.setBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, true);
  conf.setBoolean(MRJobConfig.MAPREDUCE_JOB_CLASSLOADER, true);
  Map<String, String> env = new HashMap<String, String>();
  MRApps.setClasspath(env, conf);
  String cp = env.get("CLASSPATH");
  String appCp = env.get("APP_CLASSPATH");
  assertFalse("MAPREDUCE_JOB_CLASSLOADER true, but job.jar is in the"
    + " classpath!", cp.contains("jar" + ApplicationConstants.CLASS_PATH_SEPARATOR + "job"));
  assertFalse("MAPREDUCE_JOB_CLASSLOADER true, but PWD is in the classpath!",
    cp.contains("PWD"));
  String expectedAppClasspath = StringUtils.join(ApplicationConstants.CLASS_PATH_SEPARATOR,
    Arrays.asList(ApplicationConstants.Environment.PWD.$$(), "job.jar/job.jar",
      "job.jar/classes/", "job.jar/lib/*",
      ApplicationConstants.Environment.PWD.$$() + "/*"));
  assertEquals("MAPREDUCE_JOB_CLASSLOADER true, but job.jar is not in the app"
    + " classpath!", expectedAppClasspath, appCp);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:21,代碼來源:TestMRApps.java

示例9: launchDummyTask

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
private synchronized void launchDummyTask(Container container){
    ContainerLaunchContext ctx = Records.newRecord(ContainerLaunchContext.class);
    String new_command = "./launcher.py";
    String cmd = new_command + " 1>"
        + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout"
        + " 2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR
        + "/stderr";
    ctx.setCommands(Collections.singletonList(cmd));
    ctx.setTokens(setupTokens());
    ctx.setLocalResources(this.workerResources);
    synchronized (this){
        this.nmClient.startContainerAsync(container, ctx);
    }
}
 
開發者ID:Intel-bigdata,項目名稱:MXNetOnYARN,代碼行數:15,代碼來源:ApplicationMaster.java

示例10: buildContainerContext

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
public ContainerLaunchContext buildContainerContext(Map<String, LocalResource> localResources, YacopConfig yacopConfig) {
ContainerLaunchContext ctx = null;
  try {
    List<String> commands = new ArrayList<>();
    //cmd
    Vector<CharSequence> vargs = new Vector<>(5);
    vargs.add("(" + yacopConfig.getCmd() + ")");
    vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stdout");
    vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/stderr");
    StringBuilder command = new StringBuilder();
    for (CharSequence str : vargs) {
      command.append(str).append(" ");
    }
    commands.add(command.toString());
    //tokens
    Credentials credentials = UserGroupInformation.getCurrentUser().getCredentials();
    DataOutputBuffer dob = new DataOutputBuffer();
    credentials.writeTokenStorageToStream(dob);
    ByteBuffer allTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength());
    //ctx
    ctx = ContainerLaunchContext.newInstance(localResources, null, commands, null, allTokens.duplicate(), null);
    } catch (IOException e) {
      e.printStackTrace();
    }
    return ctx;
}
 
開發者ID:intel-hadoop,項目名稱:yacop,代碼行數:27,代碼來源:SimpleContainerEngine.java

示例11: prepareCommands

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
public List<String> prepareCommands() {
    Vector<CharSequence> vargs = new Vector<CharSequence>(30);
    vargs.add(Environment.JAVA_HOME.$$() + "/bin/java");
    vargs.add("-Xmx128m");
    vargs.add(appMasterMainClass);
    vargs.add(">" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stdout");
//    vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stderr");
    vargs.add("2>&1");
    StringBuilder command = new StringBuilder();
    for (CharSequence str : vargs) {
      command.append(str).append(" ");
    }

    List<String> commands = new ArrayList<String>();
    commands.add(command.toString());

    return commands;
  }
 
開發者ID:intel-hadoop,項目名稱:yacop,代碼行數:19,代碼來源:ActionSubmitApp.java

示例12: getContainer

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@GET
@Path(PATH_PHYSICAL_PLAN_CONTAINERS + "/{containerId}")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getContainer(@PathParam("containerId") String containerId) throws Exception
{
  init();
  ContainerInfo ci = null;
  if (containerId.equals(System.getenv(ApplicationConstants.Environment.CONTAINER_ID.toString()))) {
    ci = dagManager.getAppMasterContainerInfo();
  } else {
    for (ContainerInfo containerInfo : dagManager.getCompletedContainerInfo()) {
      if (containerInfo.id.equals(containerId)) {
        ci = containerInfo;
      }
    }
    if (ci == null) {
      StreamingContainerAgent sca = dagManager.getContainerAgent(containerId);
      if (sca == null) {
        throw new NotFoundException();
      }
      ci = sca.getContainerInfo();
    }
  }
  return new JSONObject(objectMapper.writeValueAsString(ci));
}
 
開發者ID:apache,項目名稱:apex-core,代碼行數:26,代碼來源:StramWebServices.java

示例13: getEnvironmentVariables

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
/**
 * Get environment variables in a {@link java.util.Map} used when launching a Yarn container.
 *
 * @param yarnConfiguration a Hadoop {@link Configuration} object carrying Hadoop/Yarn configuration properties
 * @return a {@link java.util.Map} storing environment variables used when launching a Yarn container
 */
public static Map<String, String> getEnvironmentVariables(Configuration yarnConfiguration) {
  Map<String, String> environmentVariableMap = Maps.newHashMap();

  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.JAVA_HOME.key(),
      System.getenv(ApplicationConstants.Environment.JAVA_HOME.key()));

  // Add jars/files in the working directory of the ApplicationMaster to the CLASSPATH
  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(),
      ApplicationConstants.Environment.PWD.$());
  Apps.addToEnvironment(environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(),
      ApplicationConstants.Environment.PWD.$() + File.separator + "*");

  String[] classpaths = yarnConfiguration.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH,
      YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH);
  if (classpaths != null) {
    for (String classpath : classpaths) {
      Apps.addToEnvironment(
          environmentVariableMap, ApplicationConstants.Environment.CLASSPATH.key(), classpath.trim());
    }
  }

  return environmentVariableMap;
}
 
開發者ID:Hanmourang,項目名稱:Gobblin,代碼行數:30,代碼來源:YarnHelixUtils.java

示例14: startUp

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@Override
protected void startUp() throws Exception {
  if (this.jobConfPackagePath.isPresent()) {
    File path = new File(this.jobConfPackagePath.get());
    File jobConfigDir = new File(System.getenv().get(ApplicationConstants.Environment.PWD.key()), path.getName());
    if (jobConfigDir.exists()) {
      LOGGER.info("Loading job configurations from " + jobConfigDir);
      Properties properties = new Properties();
      properties.setProperty(ConfigurationKeys.JOB_CONFIG_FILE_DIR_KEY, jobConfigDir.getAbsolutePath());
      List<Properties> jobConfigs = SchedulerUtils.loadJobConfigs(properties);
      LOGGER.info("Loaded " + jobConfigs.size() + " job configuration(s)");
      for (Properties config : jobConfigs) {
        postNewJobConfigArrival(config.getProperty(ConfigurationKeys.JOB_NAME_KEY), config);
      }
    } else {
      LOGGER.warn("Job configuration directory " + jobConfigDir + " not found");
    }
  }
}
 
開發者ID:Hanmourang,項目名稱:Gobblin,代碼行數:20,代碼來源:JobConfigurationManager.java

示例15: testSetClasspath

import org.apache.hadoop.yarn.api.ApplicationConstants; //導入依賴的package包/類
@Test (timeout = 120000)
public void testSetClasspath() throws IOException {
  Job job = Job.getInstance();
  Map<String, String> environment = new HashMap<String, String>();
  MRApps.setClasspath(environment, job.getConfiguration());
  assertTrue(environment.get("CLASSPATH").startsWith(
    ApplicationConstants.Environment.PWD.$() + File.pathSeparator));
  String yarnAppClasspath = 
      job.getConfiguration().get(
          YarnConfiguration.YARN_APPLICATION_CLASSPATH);
  if (yarnAppClasspath != null) {
    yarnAppClasspath = yarnAppClasspath.replaceAll(",\\s*", File.pathSeparator)
      .trim();
  }
  assertTrue(environment.get("CLASSPATH").contains(yarnAppClasspath));
  String mrAppClasspath = 
      job.getConfiguration().get(MRJobConfig.MAPREDUCE_APPLICATION_CLASSPATH);
  if (mrAppClasspath != null) {
    mrAppClasspath = mrAppClasspath.replaceAll(",\\s*", File.pathSeparator)
      .trim();
  }
  assertTrue(environment.get("CLASSPATH").contains(mrAppClasspath));
}
 
開發者ID:ict-carch,項目名稱:hadoop-plus,代碼行數:24,代碼來源:TestMRApps.java


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