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


Java ContainerState类代码示例

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


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

示例1: checkState

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
private static void checkState(ContainerState state) {
  if (state == ContainerState.NEW || state == ContainerState.LOCALIZING ||
      state == ContainerState.LOCALIZED) {
    throw new NotFoundException("Container is not yet running. Current state is "
        + state);
  }
  if (state == ContainerState.LOCALIZATION_FAILED) {
    throw new NotFoundException("Container wasn't started. Localization failed.");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:ContainerLogsUtils.java

示例2: MockContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
public MockContainer(ApplicationAttemptId appAttemptId,
    Dispatcher dispatcher, Configuration conf, String user,
    ApplicationId appId, int uniqId) throws IOException{

  this.user = user;
  this.recordFactory = RecordFactoryProvider.getRecordFactory(conf);
  this.id = BuilderUtils.newContainerId(recordFactory, appId, appAttemptId,
      uniqId);
  this.launchContext = recordFactory
      .newRecordInstance(ContainerLaunchContext.class);
  long currentTime = System.currentTimeMillis();
  this.containerTokenIdentifier =
      BuilderUtils.newContainerTokenIdentifier(BuilderUtils
        .newContainerToken(id, "127.0.0.1", 1234, user,
          BuilderUtils.newResource(1024, 1), currentTime + 10000, 123,
          "password".getBytes(), currentTime));
  this.state = ContainerState.NEW;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:MockContainer.java

示例3: MockContainer

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
public MockContainer(ApplicationAttemptId appAttemptId,
    Dispatcher dispatcher, Configuration conf, String user,
    ApplicationId appId, int uniqId, String userFolder) throws IOException{

  this.user = user;
  this.userFolder = userFolder;
  this.recordFactory = RecordFactoryProvider.getRecordFactory(conf);
  this.id = BuilderUtils.newContainerId(recordFactory, appId, appAttemptId,
      uniqId);
  this.launchContext = recordFactory
      .newRecordInstance(ContainerLaunchContext.class);
  long currentTime = System.currentTimeMillis();
  this.containerTokenIdentifier =
      BuilderUtils.newContainerTokenIdentifier(BuilderUtils
        .newContainerToken(id, 0, "127.0.0.1", 1234, user,
          BuilderUtils.newResource(1024, 1), currentTime + 10000, 123,
          "password".getBytes(), currentTime));
  this.state = ContainerState.NEW;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:20,代码来源:MockContainer.java

示例4: cloneAndGetContainerStatus

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
@Override
public ContainerStatus cloneAndGetContainerStatus() {
  ContainerStatus containerStatus = recordFactory
      .newRecordInstance(ContainerStatus.class);
  containerStatus
      .setState(org.apache.hadoop.yarn.api.records.ContainerState.RUNNING);
  containerStatus.setDiagnostics("testing");
  containerStatus.setExitStatus(0);
  return containerStatus;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:MockContainer.java

示例5: addAppContainers

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
private HashMap<String, String> addAppContainers(Application app) 
    throws IOException {
  Dispatcher dispatcher = new AsyncDispatcher();
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      app.getAppId(), 1);
  Container container1 = new MockContainer(appAttemptId, dispatcher, conf,
      app.getUser(), app.getAppId(), 1,  app.getUserFolder());
  ((MockContainer)container1).setState(ContainerState.RUNNING);
  Container container2 = new MockContainer(appAttemptId, dispatcher, conf,
      app.getUser(), app.getAppId(), 2,  app.getUserFolder());
  ((MockContainer)container2).setState(ContainerState.RUNNING);
  nmContext.getContainers()
      .put(container1.getContainerId(), container1);
  nmContext.getContainers()
      .put(container2.getContainerId(), container2);
  File appDir = new File(testLogDir + "/" + app.getAppId().toString());
  appDir.mkdir();
  File container1Dir =
      new File(appDir + "/" + container1.getContainerId().toString());
  container1Dir.mkdir();
  // Create log files for containers.
  new File(container1Dir + "/" + "syslog").createNewFile();
  new File(container1Dir + "/" + "stdout").createNewFile();
  File container2Dir =
      new File(appDir + "/" + container2.getContainerId().toString());
  container2Dir.mkdir();
  new File(container2Dir + "/" + "syslog").createNewFile();
  new File(container2Dir + "/" + "stdout").createNewFile();

  app.getContainers().put(container1.getContainerId(), container1);
  app.getContainers().put(container2.getContainerId(), container2);
  HashMap<String, String> hash = new HashMap<String, String>();
  hash.put(container1.getContainerId().toString(), container1
      .getContainerId().toString());
  hash.put(container2.getContainerId().toString(), container2
      .getContainerId().toString());
  return hash;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:39,代码来源:TestNMWebServicesContainers.java

示例6: setState

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
public void setState(ContainerState state) {
  this.state = state;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:MockContainer.java

示例7: getContainerState

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
@Override
public ContainerState getContainerState() {
  return state;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:MockContainer.java

示例8: testContainerLogDirs

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
@Test(timeout=30000)
public void testContainerLogDirs() throws IOException, YarnException {
  File absLogDir = new File("target",
    TestNMWebServer.class.getSimpleName() + "LogDir").getAbsoluteFile();
  String logdirwithFile = absLogDir.toURI().toString();
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logdirwithFile);
  NodeHealthCheckerService healthChecker = createNodeHealthCheckerService(conf);
  healthChecker.init(conf);
  LocalDirsHandlerService dirsHandler = healthChecker.getDiskHandler();
  NMContext nmContext = new NodeManager.NMContext(null, null, dirsHandler,
      new ApplicationACLsManager(conf), new NMNullStateStoreService());
  // Add an application and the corresponding containers
  RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(conf);
  String user = "nobody";
  long clusterTimeStamp = 1234;
  ApplicationId appId = BuilderUtils.newApplicationId(recordFactory,
      clusterTimeStamp, 1);
  Application app = mock(Application.class);
  when(app.getUser()).thenReturn(user);
  when(app.getAppId()).thenReturn(appId);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);
  ContainerId container1 = BuilderUtils.newContainerId(recordFactory, appId,
      appAttemptId, 0);
  nmContext.getApplications().put(appId, app);

  MockContainer container =
      new MockContainer(appAttemptId, new AsyncDispatcher(), conf, user,
          appId, 1);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(container1, container);   
  List<File> files = null;
  files = ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  Assert.assertTrue(!(files.get(0).toString().contains("file:")));
  
  // After container is completed, it is removed from nmContext
  nmContext.getContainers().remove(container1);
  Assert.assertNull(nmContext.getContainers().get(container1));
  files = ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  Assert.assertTrue(!(files.get(0).toString().contains("file:")));

  // Create a new context to check if correct container log dirs are fetched
  // on full disk.
  LocalDirsHandlerService dirsHandlerForFullDisk = spy(dirsHandler);
  // good log dirs are empty and nm log dir is in the full log dir list.
  when(dirsHandlerForFullDisk.getLogDirs()).
      thenReturn(new ArrayList<String>());
  when(dirsHandlerForFullDisk.getLogDirsForRead()).
      thenReturn(Arrays.asList(new String[] {absLogDir.getAbsolutePath()}));
  nmContext = new NodeManager.NMContext(null, null, dirsHandlerForFullDisk,
      new ApplicationACLsManager(conf), new NMNullStateStoreService());
  nmContext.getApplications().put(appId, app);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(container1, container);
  List<File> dirs =
      ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  File containerLogDir = new File(absLogDir, appId + "/" + container1);
  Assert.assertTrue(dirs.contains(containerLogDir));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:61,代码来源:TestContainerLogsPage.java

示例9: testContainerLogs

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
@Test
public void testContainerLogs() throws IOException {
  WebResource r = resource();
  final ContainerId containerId = BuilderUtils.newContainerId(0, 0, 0, 0);
  final String containerIdStr = BuilderUtils.newContainerId(0, 0, 0, 0)
      .toString();
  final ApplicationAttemptId appAttemptId = containerId.getApplicationAttemptId();
  final ApplicationId appId = appAttemptId.getApplicationId();
  final String appIdStr = appId.toString();
  final String filename = "logfile1";
  final String logMessage = "log message\n";
  nmContext.getApplications().put(appId, new ApplicationImpl(null, "user",
      appId, null, nmContext));
  
  MockContainer container = new MockContainer(appAttemptId,
      new AsyncDispatcher(), new Configuration(), "user", appId, 1);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(containerId, container);
  
  // write out log file
  Path path = dirsHandler.getLogPathForWrite(
      ContainerLaunch.getRelativeContainerLogDir(
          appIdStr, containerIdStr) + "/" + filename, false);
  
  File logFile = new File(path.toUri().getPath());
  logFile.deleteOnExit();
  assertTrue("Failed to create log dir", logFile.getParentFile().mkdirs());
  PrintWriter pw = new PrintWriter(logFile);
  pw.print(logMessage);
  pw.close();

  // ask for it
  ClientResponse response = r.path("ws").path("v1").path("node")
      .path("containerlogs").path(containerIdStr).path(filename)
      .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
  String responseText = response.getEntity(String.class);
  assertEquals(logMessage, responseText);
  
  // ask for file that doesn't exist
  response = r.path("ws").path("v1").path("node")
      .path("containerlogs").path(containerIdStr).path("uhhh")
      .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
  Assert.assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
  responseText = response.getEntity(String.class);
  assertTrue(responseText.contains("Cannot find this log on the local disk."));
  
  // After container is completed, it is removed from nmContext
  nmContext.getContainers().remove(containerId);
  Assert.assertNull(nmContext.getContainers().get(containerId));
  response =
      r.path("ws").path("v1").path("node").path("containerlogs")
          .path(containerIdStr).path(filename).accept(MediaType.TEXT_PLAIN)
          .get(ClientResponse.class);
  responseText = response.getEntity(String.class);
  assertEquals(logMessage, responseText);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:57,代码来源:TestNMWebServices.java

示例10: testContainerLogFile

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
@Test(timeout=30000)
public void testContainerLogFile() throws IOException, YarnException {
  File absLogDir = new File("target",
      TestNMWebServer.class.getSimpleName() + "LogDir").getAbsoluteFile();
  String logdirwithFile = absLogDir.toURI().toString();
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logdirwithFile);
  conf.setFloat(YarnConfiguration.NM_MAX_PER_DISK_UTILIZATION_PERCENTAGE,
      0.0f);
  LocalDirsHandlerService dirsHandler = new LocalDirsHandlerService();
  dirsHandler.init(conf);
  NMContext nmContext = new NodeManager.NMContext(null, null, dirsHandler,
      new ApplicationACLsManager(conf), new NMNullStateStoreService());
  // Add an application and the corresponding containers
  String user = "nobody";
  long clusterTimeStamp = 1234;
  ApplicationId appId = BuilderUtils.newApplicationId(
      clusterTimeStamp, 1);
  Application app = mock(Application.class);
  when(app.getUser()).thenReturn(user);
  when(app.getAppId()).thenReturn(appId);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);
  ContainerId containerId = BuilderUtils.newContainerId(
      appAttemptId, 1);
  nmContext.getApplications().put(appId, app);

  MockContainer container =
      new MockContainer(appAttemptId, new AsyncDispatcher(), conf, user,
          appId, 1);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(containerId, container);
  File containerLogDir = new File(absLogDir,
      ContainerLaunch.getRelativeContainerLogDir(appId.toString(),
          containerId.toString()));
  containerLogDir.mkdirs();
  String fileName = "fileName";
  File containerLogFile = new File(containerLogDir, fileName);
  containerLogFile.createNewFile();
  File file = ContainerLogsUtils.getContainerLogFile(containerId,
      fileName, user, nmContext);
  Assert.assertEquals(containerLogFile.toURI().toString(),
      file.toURI().toString());
  FileUtil.fullyDelete(absLogDir);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:46,代码来源:TestContainerLogsPage.java

示例11: testContainerLogDirs

import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState; //导入依赖的package包/类
@Test(timeout=30000)
public void testContainerLogDirs() throws IOException, YarnException {
  File absLogDir = new File("target",
    TestNMWebServer.class.getSimpleName() + "LogDir").getAbsoluteFile();
  String logdirwithFile = absLogDir.toURI().toString();
  Configuration conf = new Configuration();
  conf.set(YarnConfiguration.NM_LOG_DIRS, logdirwithFile);
  NodeHealthCheckerService healthChecker = new NodeHealthCheckerService();
  healthChecker.init(conf);
  LocalDirsHandlerService dirsHandler = healthChecker.getDiskHandler();
  NMContext nmContext = new NodeManager.NMContext(null, null, dirsHandler,
      new ApplicationACLsManager(conf), new NMNullStateStoreService(), null);
  // Add an application and the corresponding containers
  RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(conf);
  String user = "nobody";
  long clusterTimeStamp = 1234;
  ApplicationId appId = BuilderUtils.newApplicationId(recordFactory,
      clusterTimeStamp, 1);
  Application app = mock(Application.class);
  when(app.getUser()).thenReturn(user);
  when(app.getAppId()).thenReturn(appId);
  ApplicationAttemptId appAttemptId = BuilderUtils.newApplicationAttemptId(
      appId, 1);
  ContainerId container1 = BuilderUtils.newContainerId(recordFactory, appId,
      appAttemptId, 0);
  nmContext.getApplications().put(appId, app);

  MockContainer container =
      new MockContainer(appAttemptId, new AsyncDispatcher(), conf, user,
          appId, 1);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(container1, container);   
  List<File> files = null;
  files = ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  Assert.assertTrue(!(files.get(0).toString().contains("file:")));
  
  // After container is completed, it is removed from nmContext
  nmContext.getContainers().remove(container1);
  Assert.assertNull(nmContext.getContainers().get(container1));
  files = ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  Assert.assertTrue(!(files.get(0).toString().contains("file:")));

  // Create a new context to check if correct container log dirs are fetched
  // on full disk.
  LocalDirsHandlerService dirsHandlerForFullDisk = spy(dirsHandler);
  // good log dirs are empty and nm log dir is in the full log dir list.
  when(dirsHandlerForFullDisk.getLogDirs()).
      thenReturn(new ArrayList<String>());
  when(dirsHandlerForFullDisk.getLogDirsForRead()).
      thenReturn(Arrays.asList(new String[] {absLogDir.getAbsolutePath()}));
  nmContext = new NodeManager.NMContext(null, null, dirsHandlerForFullDisk,
      new ApplicationACLsManager(conf), new NMNullStateStoreService(), null);
  nmContext.getApplications().put(appId, app);
  container.setState(ContainerState.RUNNING);
  nmContext.getContainers().put(container1, container);
  List<File> dirs =
      ContainerLogsUtils.getContainerLogDirs(container1, user, nmContext);
  File containerLogDir = new File(absLogDir, appId + "/" + container1);
  Assert.assertTrue(dirs.contains(containerLogDir));
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:61,代码来源:TestContainerLogsPage.java


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