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


Java ConverterUtils.toContainerId方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.util.ConverterUtils.toContainerId方法的典型用法代码示例。如果您正苦于以下问题:Java ConverterUtils.toContainerId方法的具体用法?Java ConverterUtils.toContainerId怎么用?Java ConverterUtils.toContainerId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.util.ConverterUtils的用法示例。


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

示例1: sendErrorMessage

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
private void sendErrorMessage() throws InterruptedException {
  List<TaskState> stateList = Arrays.asList(
      TaskState.CONTAINER_ALLOCATED, TaskState.CONTAINER_LAUNCHED, TaskState.CONTAINER_RUNNING);
  List<TaskStatus> list = statusManager.getTaskStatus(new HashSet<>(stateList));
  while (list.size() < taskNum) {
    Thread.sleep(2000);
    list = statusManager.getTaskStatus(new HashSet<>(stateList));
  }

  String containerIdStr = list.get(0).getContainerId();
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);

  ContainerStatus status = Records.newRecord(ContainerStatus.class);
  status.setContainerId(containerId);
  status.setState(ContainerState.COMPLETE);
  status.setExitStatus(ExitStatusKey.SUCCEEDED.toInt());
  onContainersCompleted(Collections.singletonList(status));
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:19,代码来源:KillAllOnAnyCompletedTest.java

示例2: verifyAndGetContainerId

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
private ContainerId verifyAndGetContainerId(Block html) {
  String containerIdStr = $(CONTAINER_ID);
  if (containerIdStr == null || containerIdStr.isEmpty()) {
    html.h1()._("Cannot get container logs without a ContainerId")._();
    return null;
  }
  ContainerId containerId = null;
  try {
    containerId = ConverterUtils.toContainerId(containerIdStr);
  } catch (IllegalArgumentException e) {
    html.h1()
        ._("Cannot get container logs for invalid containerId: "
            + containerIdStr)._();
    return null;
  }
  return containerId;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:AggregatedLogsBlock.java

示例3: openLogFileForRead

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
public static FileInputStream openLogFileForRead(String containerIdStr, File logFile,
    Context context) throws IOException {
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
  ApplicationId applicationId = containerId.getApplicationAttemptId()
      .getApplicationId();
  String user = context.getApplications().get(
      applicationId).getUser();
  
  try {
    return SecureIOUtils.openForRead(logFile, user, null);
  } catch (IOException e) {
    if (e.getMessage().contains(
      "did not match expected owner '" + user
          + "'")) {
      LOG.error(
          "Exception reading log file " + logFile.getAbsolutePath(), e);
      throw new IOException("Exception reading log file. Application submitted by '"
          + user
          + "' doesn't own requested log file : "
          + logFile.getName(), e);
    } else {
      throw new IOException("Exception reading log file. It might be because log "
          + "file was aggregated : " + logFile.getName(), e);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:ContainerLogsUtils.java

示例4: getNodeContainer

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@GET
@Path("/containers/{containerid}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public ContainerInfo getNodeContainer(@PathParam("containerid") String id) {
  ContainerId containerId = null;
  init();
  try {
    containerId = ConverterUtils.toContainerId(id);
  } catch (Exception e) {
    throw new BadRequestException("invalid container id, " + id);
  }

  Container container = nmContext.getContainers().get(containerId);
  if (container == null) {
    throw new NotFoundException("container with id, " + id + ", not found");
  }
  return new ContainerInfo(this.nmContext, container, uriInfo.getBaseUri()
      .toString(), webapp.name());

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

示例5: testMRAppMasterForDifferentUser

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@Test
public void testMRAppMasterForDifferentUser() throws IOException,
    InterruptedException {
  String applicationAttemptIdStr = "appattempt_1317529182569_0004_000001";
  String containerIdStr = "container_1317529182569_0004_000001_1";
  
  String userName = "TestAppMasterUser";
  ApplicationAttemptId applicationAttemptId = ConverterUtils
      .toApplicationAttemptId(applicationAttemptIdStr);
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
  MRAppMasterTest appMaster =
      new MRAppMasterTest(applicationAttemptId, containerId, "host", -1, -1,
          System.currentTimeMillis());
  JobConf conf = new JobConf();
  conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
  MRAppMaster.initAndStartAppMaster(appMaster, conf, userName);
  Path userPath = new Path(stagingDir, userName);
  Path userStagingPath = new Path(userPath, ".staging");
  assertEquals(userStagingPath.toString(),
    appMaster.stagingDirPath.toString());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestMRAppMaster.java

示例6: getAllContainers

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
public List<ContainerId> getAllContainers(String applicationId,
    Configuration conf) {
  List<ContainerId> containers = new ArrayList<ContainerId>();
  String[] logDirs = HPCConfiguration.getHPCLogDirs(conf);
  for (String logDir : logDirs) {
    File appDir = new File(logDir, applicationId);
    if (appDir.exists()) {
      String[] containerDirs = appDir.list();
      if (containerDirs != null) {
        for (String containerDir : containerDirs) {
          try {
            ContainerId containerId = ConverterUtils
                .toContainerId(containerDir);
            containers.add(containerId);
          } catch (Exception e) {
            // Skip the non container dir's
            LOG.debug("Skipping non container dir : " + containerDir, e);
          }
        }
      }
    }
  }
  return containers;
}
 
开发者ID:intel-hpdd,项目名称:scheduling-connector-for-hadoop,代码行数:25,代码来源:HPCLogAggregateHandler.java

示例7: initContainerList

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
public static void initContainerList(List<Container> containerList, int length, Resource resource) {
  for (int i = 0; i < length; i++) {
    String containerIdStr = "container_" + System.currentTimeMillis() + "_0001_000001_" + (i + 2);
    ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
    NodeId nodeId = NodeId.newInstance(GlobalConstants.LOCAL_HOST_NAME, 3215);
    Container container = Container.newInstance(containerId,
        nodeId, GlobalConstants.LOCAL_HOST_NAME, resource, Priority.newInstance(1), null);
    containerList.add(container);
  }
}
 
开发者ID:Microsoft,项目名称:pai,代码行数:11,代码来源:FeatureTestUtils.java

示例8: parseContainerId

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
protected static ContainerId parseContainerId(String containerId) {
  if (containerId == null || containerId.isEmpty()) {
    throw new NotFoundException("containerId, " + containerId
        + ", is empty or null");
  }
  ContainerId cid = ConverterUtils.toContainerId(containerId);
  if (cid == null) {
    throw new NotFoundException("containerId is null");
  }
  return cid;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:WebServices.java

示例9: logs

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
public void logs() {
  String containerIdStr = $(CONTAINER_ID);
  ContainerId containerId = null;
  try {
    containerId = ConverterUtils.toContainerId(containerIdStr);
  } catch (IllegalArgumentException e) {
    render(ContainerLogsPage.class);
    return;
  }
  ApplicationId appId =
      containerId.getApplicationAttemptId().getApplicationId();
  Application app = nmContext.getApplications().get(appId);
  if (app == null
      && nmConf.getBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED,
          YarnConfiguration.DEFAULT_LOG_AGGREGATION_ENABLED)) {
    String logServerUrl = nmConf.get(YarnConfiguration.YARN_LOG_SERVER_URL);
    String redirectUrl = null;
    if (logServerUrl == null || logServerUrl.isEmpty()) {
      redirectUrl = "false";
    } else {
      redirectUrl =
          url(logServerUrl, nmContext.getNodeId().toString(), containerIdStr,
              containerIdStr, $(APP_OWNER));
    }
    set(ContainerLogsPage.REDIRECT_URL, redirectUrl);
  }
  render(ContainerLogsPage.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:NMController.java

示例10: render

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@Override
protected void render(Block html) {
  ContainerId containerID;
  try {
    containerID = ConverterUtils.toContainerId($(CONTAINER_ID));
  } catch (IllegalArgumentException e) {
    html.p()._("Invalid containerId " + $(CONTAINER_ID))._();
    return;
  }

  DIV<Hamlet> div = html.div("#content");
  Container container = this.nmContext.getContainers().get(containerID);
  if (container == null) {
    div.h1("Unknown Container. Container might have completed, "
            + "please go back to the previous page and retry.")._();
    return;
  }
  ContainerInfo info = new ContainerInfo(this.nmContext, container);

  info("Container information")
    ._("ContainerID", info.getId())
    ._("ContainerState", info.getState())
    ._("ExitStatus", info.getExitStatus())
    ._("Diagnostics", info.getDiagnostics())
    ._("User", info.getUser())
    ._("TotalMemoryNeeded", info.getMemoryNeeded())
    ._("TotalVCoresNeeded", info.getVCoresNeeded())
    ._("logs", info.getShortLogLink(), "Link to logs");
  html._(InfoBlock.class);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:ContainerPage.java

示例11: loadContainerToken

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
private static void loadContainerToken(RecoveredContainerTokensState state,
    String key, String containerIdStr, byte[] value) throws IOException {
  ContainerId containerId;
  Long expTime;
  try {
    containerId = ConverterUtils.toContainerId(containerIdStr);
    expTime = Long.parseLong(asString(value));
  } catch (IllegalArgumentException e) {
    throw new IOException("Bad container token state for " + key, e);
  }
  state.activeTokens.put(containerId, expTime);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:NMLeveldbStateStoreService.java

示例12: testMRAppMasterMidLock

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@Test
public void testMRAppMasterMidLock() throws IOException,
    InterruptedException {
  String applicationAttemptIdStr = "appattempt_1317529182569_0004_000002";
  String containerIdStr = "container_1317529182569_0004_000002_1";
  String userName = "TestAppMasterUser";
  JobConf conf = new JobConf();
  conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
  ApplicationAttemptId applicationAttemptId = ConverterUtils
      .toApplicationAttemptId(applicationAttemptIdStr);
  JobId jobId =  TypeConverter.toYarn(
      TypeConverter.fromYarn(applicationAttemptId.getApplicationId()));
  Path start = MRApps.getStartJobCommitFile(conf, userName, jobId);
  FileSystem fs = FileSystem.get(conf);
  //Create the file, but no end file so we should unregister with an error.
  fs.create(start).close();
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
  MRAppMaster appMaster =
      new MRAppMasterTest(applicationAttemptId, containerId, "host", -1, -1,
          System.currentTimeMillis(), false, false);
  boolean caught = false;
  try {
    MRAppMaster.initAndStartAppMaster(appMaster, conf, userName);
  } catch (IOException e) {
    //The IO Exception is expected
    LOG.info("Caught expected Exception", e);
    caught = true;
  }
  assertTrue(caught);
  assertTrue(appMaster.errorHappenedShutDown);
  assertEquals(JobStateInternal.ERROR, appMaster.forcedState);
  appMaster.stop();

  // verify the final status is FAILED
  verifyFailedStatus((MRAppMasterTest)appMaster, "FAILED");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestMRAppMaster.java

示例13: testMRAppMasterFailLock

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@Test
public void testMRAppMasterFailLock() throws IOException,
    InterruptedException {
  String applicationAttemptIdStr = "appattempt_1317529182569_0004_000002";
  String containerIdStr = "container_1317529182569_0004_000002_1";
  String userName = "TestAppMasterUser";
  JobConf conf = new JobConf();
  conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
  ApplicationAttemptId applicationAttemptId = ConverterUtils
      .toApplicationAttemptId(applicationAttemptIdStr);
  JobId jobId =  TypeConverter.toYarn(
      TypeConverter.fromYarn(applicationAttemptId.getApplicationId()));
  Path start = MRApps.getStartJobCommitFile(conf, userName, jobId);
  Path end = MRApps.getEndJobCommitFailureFile(conf, userName, jobId);
  FileSystem fs = FileSystem.get(conf);
  fs.create(start).close();
  fs.create(end).close();
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
  MRAppMaster appMaster =
      new MRAppMasterTest(applicationAttemptId, containerId, "host", -1, -1,
          System.currentTimeMillis(), false, false);
  boolean caught = false;
  try {
    MRAppMaster.initAndStartAppMaster(appMaster, conf, userName);
  } catch (IOException e) {
    //The IO Exception is expected
    LOG.info("Caught expected Exception", e);
    caught = true;
  }
  assertTrue(caught);
  assertTrue(appMaster.errorHappenedShutDown);
  assertEquals(JobStateInternal.FAILED, appMaster.forcedState);
  appMaster.stop();

  // verify the final status is FAILED
  verifyFailedStatus((MRAppMasterTest)appMaster, "FAILED");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:TestMRAppMaster.java

示例14: testMRAppMasterMissingStaging

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
@Test
public void testMRAppMasterMissingStaging() throws IOException,
    InterruptedException {
  String applicationAttemptIdStr = "appattempt_1317529182569_0004_000002";
  String containerIdStr = "container_1317529182569_0004_000002_1";
  String userName = "TestAppMasterUser";
  JobConf conf = new JobConf();
  conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
  ApplicationAttemptId applicationAttemptId = ConverterUtils
      .toApplicationAttemptId(applicationAttemptIdStr);

  //Delete the staging directory
  File dir = new File(stagingDir);
  if(dir.exists()) {
    FileUtils.deleteDirectory(dir);
  }
  
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
  MRAppMaster appMaster =
      new MRAppMasterTest(applicationAttemptId, containerId, "host", -1, -1,
          System.currentTimeMillis(), false, false);
  boolean caught = false;
  try {
    MRAppMaster.initAndStartAppMaster(appMaster, conf, userName);
  } catch (IOException e) {
    //The IO Exception is expected
    LOG.info("Caught expected Exception", e);
    caught = true;
  }
  assertTrue(caught);
  assertTrue(appMaster.errorHappenedShutDown);
  //Copying the history file is disabled, but it is not really visible from 
  //here
  assertEquals(JobStateInternal.ERROR, appMaster.forcedState);
  appMaster.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:37,代码来源:TestMRAppMaster.java

示例15: main

import org.apache.hadoop.yarn.util.ConverterUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
  // get configuration from config file
  Configuration conf = new Configuration();
  conf.addResource(AngelConf.ANGEL_JOB_CONF_FILE);

  String containerIdStr = System.getenv(Environment.CONTAINER_ID.name());
  ContainerId containerId = ConverterUtils.toContainerId(containerIdStr);
  ApplicationAttemptId applicationAttemptId = containerId.getApplicationAttemptId();
  ApplicationId appId = applicationAttemptId.getApplicationId();
  String user = System.getenv(Environment.USER.name());

  // set localDir with enviroment set by nm.
  String[] localSysDirs =
      StringUtils.getTrimmedStrings(System.getenv(Environment.LOCAL_DIRS.name()));
  conf.setStrings(AngelConf.LOCAL_DIR, localSysDirs);
  LOG.info(AngelConf.LOCAL_DIR + " for child: " + conf.get(AngelConf.LOCAL_DIR));

  String psAgentindex = System.getenv(AngelEnvironment.PSAGENT_ID.name());
  String psAgentAttemptIndex = System.getenv(AngelEnvironment.PSAGENT_ATTEMPT_ID.name());
  String masterAddr = System.getenv(AngelEnvironment.LISTEN_ADDR.name());
  String portStr = System.getenv(AngelEnvironment.LISTEN_PORT.name());
  Location masterLocation = new Location(masterAddr, Integer.valueOf(portStr));

  LOG.info("psAgentindex=" + psAgentindex);
  LOG.info("psAgentAttemptIndex=" + psAgentAttemptIndex);
  LOG.info("masterLocation=" + masterLocation);
  LOG.info("user=" + user);
  LOG.info("appId=" + appId);

  PSAgentId psAgentId = new PSAgentId(Integer.valueOf(psAgentindex));
  PSAgentAttemptId psAgentAttemptId =
      new PSAgentAttemptId(psAgentId, Integer.valueOf(psAgentAttemptIndex));

  try {
    PSAgent psAgent =
        new PSAgent(conf, appId, user, psAgentAttemptId, masterAddr, Integer.valueOf(portStr),
            true, null);
    psAgent.initAndStart();
  } catch (Exception e) {
    LOG.fatal("Failed to start worker.", e);
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:43,代码来源:PSAgent.java


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