当前位置: 首页>>代码示例>>Java>>正文


Java YarnConfiguration类代码示例

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


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

示例1: initAndStartStore

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
private void initAndStartStore(final FileSystem fs) throws IOException,
    URISyntaxException {
  Configuration conf = new Configuration();
  fs.initialize(new URI("/"), conf);
  fsWorkingPath =
      new Path("target",
        TestFileSystemApplicationHistoryStore.class.getSimpleName());
  fs.delete(fsWorkingPath, true);
  conf.set(YarnConfiguration.FS_APPLICATION_HISTORY_STORE_URI,
    fsWorkingPath.toString());
  store = new FileSystemApplicationHistoryStore() {
    @Override
    protected FileSystem getFileSystem(Path path, Configuration conf) {
      return fs;
    }
  };
  store.init(conf);
  store.start();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestFileSystemApplicationHistoryStore.java

示例2: testUnhealthyNodeStatus

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test
public void testUnhealthyNodeStatus() throws Exception {
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, hostFile
      .getAbsolutePath());

  rm = new MockRM(conf);
  rm.start();

  MockNM nm1 = rm.registerNode("host1:1234", 5120);
  Assert.assertEquals(0, ClusterMetrics.getMetrics().getUnhealthyNMs());
  // node healthy
  nm1.nodeHeartbeat(true);

  // node unhealthy
  nm1.nodeHeartbeat(false);
  checkUnealthyNMCount(rm, nm1, true, 1);

  // node healthy again
  nm1.nodeHeartbeat(true);
  checkUnealthyNMCount(rm, nm1, false, 0);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestResourceTrackerService.java

示例3: testEmptyYarnClasspath

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test
public void testEmptyYarnClasspath() throws Exception {
  assumeNonMaprProfile();
  DacDaemonYarnApplication.Environment myEnv = new DacDaemonYarnApplication.Environment() {
    public String getEnv(String name) {
      return tempDir.getRoot().toString();
    }
  };

  YarnConfiguration yarnConfiguration = createYarnConfig("resource-manager", "hdfs://name-node:8020");
  yarnConfiguration.set(YarnDefaultsConfigurator.APP_CLASSPATH_JARS, YarnDefaultsConfigurator.MapRYarnDefaults.getAppClassPath());
  DacDaemonYarnApplication dacDaemonApp = new DacDaemonYarnApplication(DremioConfig.create(),
    yarnConfiguration, myEnv);

  List<String> names = dacDaemonApp.getJarNames();
  assertFalse(names.isEmpty());
  assertEquals(2, names.size());

  String flatNames = names.toString();
  assertTrue(flatNames.contains(SHIM_LOADER_NAME));
  assertTrue(flatNames.contains("maprfs-5.1.0-mapr.jar"));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:TestYarnController.java

示例4: testContainerLaunch

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test
public void testContainerLaunch() throws Exception {
  Assume.assumeTrue(shouldRun());
  String expectedRunAsUser =
      conf.get(YarnConfiguration.NM_NONSECURE_MODE_LOCAL_USER_KEY,
        YarnConfiguration.DEFAULT_NM_NONSECURE_MODE_LOCAL_USER);

  File touchFile = new File(workSpace, "touch-file");
  int ret = runAndBlock("touch", touchFile.getAbsolutePath());

  assertEquals(0, ret);
  FileStatus fileStatus =
      FileContext.getLocalFSFileContext().getFileStatus(
        new Path(touchFile.getAbsolutePath()));
  assertEquals(expectedRunAsUser, fileStatus.getOwner());
  cleanupAppFiles(expectedRunAsUser);

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

示例5: createNMConfig

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
private YarnConfiguration createNMConfig() {
  YarnConfiguration conf = new YarnConfiguration();
  String localhostAddress = null;
  try {
    localhostAddress = InetAddress.getByName("localhost").getCanonicalHostName();
  } catch (UnknownHostException e) {
    Assert.fail("Unable to get localhost address: " + e.getMessage());
  }
  conf.setInt(YarnConfiguration.NM_PMEM_MB, 5 * 1024); // 5GB
  conf.set(YarnConfiguration.NM_ADDRESS, localhostAddress + ":12345");
  conf.set(YarnConfiguration.NM_LOCALIZER_ADDRESS, localhostAddress + ":12346");
  conf.set(YarnConfiguration.NM_LOG_DIRS, logsDir.getAbsolutePath());
  conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR,
    remoteLogsDir.getAbsolutePath());
  conf.set(YarnConfiguration.NM_LOCAL_DIRS, nmLocalDir.getAbsolutePath());
  conf.setLong(YarnConfiguration.NM_LOG_RETAIN_SECONDS, 1);
  return conf;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestNodeStatusUpdater.java

示例6: launchJobHistoryServer

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
static JobHistoryServer launchJobHistoryServer(String[] args) {
  Thread.
      setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(JobHistoryServer.class, args, LOG);
  JobHistoryServer jobHistoryServer = null;
  try {
    jobHistoryServer = new JobHistoryServer();
    ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(jobHistoryServer),
        SHUTDOWN_HOOK_PRIORITY);
    YarnConfiguration conf = new YarnConfiguration(new JobConf());
    new GenericOptionsParser(conf, args);
    jobHistoryServer.init(conf);
    jobHistoryServer.start();
  } catch (Throwable t) {
    LOG.fatal("Error starting JobHistoryServer", t);
    ExitUtil.terminate(-1, "Error starting JobHistoryServer");
  }
  return jobHistoryServer;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:JobHistoryServer.java

示例7: testAuxUnexpectedStop

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test
public void testAuxUnexpectedStop() {
  Configuration conf = new Configuration();
  conf.setStrings(YarnConfiguration.NM_AUX_SERVICES, new String[] { "Asrv", "Bsrv" });
  conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Asrv"),
      ServiceA.class, Service.class);
  conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Bsrv"),
      ServiceB.class, Service.class);
  final AuxServices aux = new AuxServices();
  aux.init(conf);
  aux.start();

  Service s = aux.getServices().iterator().next();
  s.stop();
  assertEquals("Auxiliary service stopped, but AuxService unaffected.",
      STOPPED, aux.getServiceState());
  assertTrue(aux.getServices().isEmpty());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestAuxServices.java

示例8: createApplicationHistoryStore

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
protected ApplicationHistoryStore createApplicationHistoryStore(
    Configuration conf) {
  return ReflectionUtils.newInstance(conf.getClass(
    YarnConfiguration.APPLICATION_HISTORY_STORE,
    FileSystemApplicationHistoryStore.class,
    ApplicationHistoryStore.class), conf);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:ApplicationHistoryManagerImpl.java

示例9: testLaunchContainer

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test
public void testLaunchContainer() throws IOException {
  if (!shouldRun()) {
    LOG.warn("Docker not installed, aborting test.");
    return;
  }

  Map<String, String> env = new HashMap<String, String>();
  env.put(YarnConfiguration.NM_DOCKER_CONTAINER_EXECUTOR_IMAGE_NAME, testImage);
  String touchFileName = "touch-file-" + System.currentTimeMillis();
  File touchFile = new File(dirsHandler.getLocalDirs().get(0), touchFileName);
  ContainerId cId = getNextContainerId();
  int ret = runAndBlock(
      cId, env, "touch", touchFile.getAbsolutePath(), "&&", "cp", touchFile.getAbsolutePath(), "/");

  assertEquals(0, ret);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestDockerContainerExecutor.java

示例10: testCorruptedOwnerInfoForDomain

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test
public void testCorruptedOwnerInfoForDomain() 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);
  TimelineDomain domain = new TimelineDomain();
  try {
    timelineACLsManager.checkAccess(
        UserGroupInformation.createRemoteUser("owner"), domain);
    Assert.fail("Exception is expected");
  } catch (YarnException e) {
    Assert.assertTrue("It's not the exact expected exception", e.getMessage()
        .contains("is corrupted."));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestTimelineACLsManager.java

示例11: createPlanFollower

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
private PlanFollower createPlanFollower() {
  String planFollowerPolicyClassName =
      conf.get(YarnConfiguration.RM_RESERVATION_SYSTEM_PLAN_FOLLOWER,
          getDefaultPlanFollower());
  if (planFollowerPolicyClassName == null) {
    return null;
  }
  LOG.info("Using PlanFollowerPolicy: " + planFollowerPolicyClassName);
  try {
    Class<?> planFollowerPolicyClazz =
        conf.getClassByName(planFollowerPolicyClassName);
    if (PlanFollower.class.isAssignableFrom(planFollowerPolicyClazz)) {
      return (PlanFollower) ReflectionUtils.newInstance(
          planFollowerPolicyClazz, conf);
    } else {
      throw new YarnRuntimeException("Class: " + planFollowerPolicyClassName
          + " not instance of " + PlanFollower.class.getCanonicalName());
    }
  } catch (ClassNotFoundException e) {
    throw new YarnRuntimeException(
        "Could not instantiate PlanFollowerPolicy: "
            + planFollowerPolicyClassName, e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:AbstractReservationSystem.java

示例12: testVerifyAccessPublicResource

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
/**
 * If resource is public, verifyAccess should succeed
 */
@Test
public void testVerifyAccessPublicResource() throws Exception {
  Configuration conf = new Configuration();
  conf.setBoolean(YarnConfiguration.SHARED_CACHE_ENABLED, true);
  LocalResource resource = mock(LocalResource.class);
  // give public visibility
  when(resource.getVisibility()).thenReturn(LocalResourceVisibility.PUBLIC);
  Path localPath = mock(Path.class);
  when(localPath.getName()).thenReturn("foo.jar");
  String user = "joe";
  SCMUploaderProtocol scmClient = mock(SCMUploaderProtocol.class);
  FileSystem fs = mock(FileSystem.class);
  FileSystem localFs = FileSystem.getLocal(conf);
  SharedCacheUploader spied =
      createSpiedUploader(resource, localPath, user, conf, scmClient, fs,
          localFs);

  assertTrue(spied.verifyAccess());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestSharedCacheUploader.java

示例13: testAuxServiceRecoverySetup

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test
public void testAuxServiceRecoverySetup() throws IOException {
  Configuration conf = new YarnConfiguration();
  conf.setBoolean(YarnConfiguration.NM_RECOVERY_ENABLED, true);
  conf.set(YarnConfiguration.NM_RECOVERY_DIR, TEST_DIR.toString());
  conf.setStrings(YarnConfiguration.NM_AUX_SERVICES,
      new String[] { "Asrv", "Bsrv" });
  conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Asrv"),
      RecoverableServiceA.class, Service.class);
  conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, "Bsrv"),
      RecoverableServiceB.class, Service.class);
  try {
    final AuxServices aux = new AuxServices();
    aux.init(conf);
    Assert.assertEquals(2, aux.getServices().size());
    File auxStorageDir = new File(TEST_DIR,
        AuxServices.STATE_STORE_ROOT_NAME);
    Assert.assertEquals(2, auxStorageDir.listFiles().length);
    aux.close();
  } finally {
    FileUtil.fullyDelete(TEST_DIR);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestAuxServices.java

示例14: checkTags

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
private void checkTags(Set<String> tags) {
  if (tags.size() > YarnConfiguration.APPLICATION_MAX_TAGS) {
    throw new IllegalArgumentException("Too many applicationTags, a maximum of only "
        + YarnConfiguration.APPLICATION_MAX_TAGS + " are allowed!");
  }
  for (String tag : tags) {
    if (tag.length() > YarnConfiguration.APPLICATION_MAX_TAG_LENGTH) {
      throw new IllegalArgumentException("Tag " + tag + " is too long, " +
          "maximum allowed length of a tag is " +
          YarnConfiguration.APPLICATION_MAX_TAG_LENGTH);
    }
    if (!CharMatcher.ASCII.matchesAllOf(tag)) {
      throw new IllegalArgumentException("A tag can only have ASCII " +
          "characters! Invalid tag - " + tag);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:ApplicationSubmissionContextPBImpl.java

示例15: testLaunchWithArguments

import org.apache.hadoop.yarn.conf.YarnConfiguration; //导入依赖的package包/类
@Test(timeout = 60000)
public void testLaunchWithArguments() throws Exception {
  ExitUtil.disableSystemExit();
  ApplicationHistoryServer historyServer = null;
  try {
    // Not able to modify the config of this test case,
    // but others have been customized to avoid conflicts
    String[] args = new String[2];
    args[0]="-D" + YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS + "=4000";
    args[1]="-D" + YarnConfiguration.TIMELINE_SERVICE_TTL_MS + "=200";
    historyServer =
        ApplicationHistoryServer.launchAppHistoryServer(args);
    Configuration conf = historyServer.getConfig();
    assertEquals("4000", conf.get(YarnConfiguration.TIMELINE_SERVICE_LEVELDB_TTL_INTERVAL_MS));
    assertEquals("200", conf.get(YarnConfiguration.TIMELINE_SERVICE_TTL_MS));
  } catch (ExitUtil.ExitException e) {
    assertEquals(0, e.status);
    ExitUtil.resetFirstExitException();
    fail();
  } finally {
    if (historyServer != null) {
      historyServer.stop();
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestApplicationHistoryServer.java


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