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


Java ProcessIdFileReader类代码示例

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


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

示例1: getContainerPid

import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader; //导入依赖的package包/类
/**
 * Loop through for a time-bounded interval waiting to
 * read the process id from a file generated by a running process.
 * @param pidFilePath File from which to read the process id
 * @return Process ID
 * @throws Exception
 */
private String getContainerPid(Path pidFilePath) throws Exception {
  String containerIdStr = 
      ConverterUtils.toString(container.getContainerId());
  String processId = null;
  LOG.debug("Accessing pid for container " + containerIdStr
      + " from pid file " + pidFilePath);
  int sleepCounter = 0;
  final int sleepInterval = 100;

  // loop waiting for pid file to show up 
  // until our timer expires in which case we admit defeat
  while (true) {
    processId = ProcessIdFileReader.getProcessId(pidFilePath);
    if (processId != null) {
      LOG.debug("Got pid " + processId + " for container "
          + containerIdStr);
      break;
    }
    else if ((sleepCounter*sleepInterval) > maxKillWaitTime) {
      LOG.info("Could not get pid for " + containerIdStr
      		+ ". Waited for " + maxKillWaitTime + " ms.");
      break;
    }
    else {
      ++sleepCounter;
      Thread.sleep(sleepInterval);
    }
  }
  return processId;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:ContainerLaunch.java

示例2: getProcessId

import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader; //导入依赖的package包/类
/**
 * Get the process-identifier for the container
 * 
 * @param containerID
 * @return the processid of the container if it has already launched,
 *         otherwise return null
 */
public String getProcessId(ContainerId containerID) {
  String pid = null;
  Path pidFile = pidFiles.get(containerID);
  if (pidFile == null) {
    // This container isn't even launched yet.
    return pid;
  }
  try {
    pid = ProcessIdFileReader.getProcessId(pidFile);
  } catch (IOException e) {
    LOG.error("Got exception reading pid from pid-file " + pidFile, e);
  }
  return pid;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:ContainerExecutor.java

示例3: testNullPath

import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader; //导入依赖的package包/类
@Test (timeout = 30000)
public void testNullPath() {
  String pid = null;
  try {
    pid = ProcessIdFileReader.getProcessId(null);
    fail("Expected an error to be thrown for null path");
  } catch (Exception e) {
    // expected
  }
  assert(pid == null);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestProcessIdFileReader.java

示例4: testSimpleGet

import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader; //导入依赖的package包/类
@Test (timeout = 30000)
public void testSimpleGet() throws IOException {
  String rootDir = new File(System.getProperty(
      "test.build.data", "/tmp")).getAbsolutePath();
  File testFile = null;
  String expectedProcessId = Shell.WINDOWS ?
    "container_1353742680940_0002_01_000001" :
    "56789";
  
  try {
    testFile = new File(rootDir, "temp.txt");
    PrintWriter fileWriter = new PrintWriter(testFile);
    fileWriter.println(expectedProcessId);
    fileWriter.close();      
    String processId = null; 
                
    processId = ProcessIdFileReader.getProcessId(
        new Path(rootDir + Path.SEPARATOR + "temp.txt"));
    Assert.assertEquals(expectedProcessId, processId);      
    
  } finally {
    if (testFile != null
        && testFile.exists()) {
      testFile.delete();
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:28,代码来源:TestProcessIdFileReader.java

示例5: testComplexGet

import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader; //导入依赖的package包/类
@Test (timeout = 30000)
public void testComplexGet() throws IOException {
  String rootDir = new File(System.getProperty(
      "test.build.data", "/tmp")).getAbsolutePath();
  File testFile = null;
  String processIdInFile = Shell.WINDOWS ?
    " container_1353742680940_0002_01_000001 " :
    " 23 ";
  String expectedProcessId = processIdInFile.trim();
  try {
    testFile = new File(rootDir, "temp.txt");
    PrintWriter fileWriter = new PrintWriter(testFile);
    fileWriter.println("   ");
    fileWriter.println("");
    fileWriter.println("abc");
    fileWriter.println("-123");
    fileWriter.println("-123 ");
    fileWriter.println(processIdInFile);
    fileWriter.println("6236");
    fileWriter.close();      
    String processId = null; 
                
    processId = ProcessIdFileReader.getProcessId(
        new Path(rootDir + Path.SEPARATOR + "temp.txt"));
    Assert.assertEquals(expectedProcessId, processId);
    
  } finally {
    if (testFile != null
        && testFile.exists()) {
      testFile.delete();
    }
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:34,代码来源:TestProcessIdFileReader.java

示例6: getContainerPid

import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader; //导入依赖的package包/类
/**
 * Loop through for a time-bounded interval waiting to
 * read the process id from a file generated by a running process.
 * @param pidFilePath File from which to read the process id
 * @return Process ID
 * @throws Exception
 */
private String getContainerPid(Path pidFilePath) throws Exception {
  String containerIdStr = 
      ConverterUtils.toString(container.getContainerId());
  String processId = null;
  LOG.debug("Accessing pid for container " + containerIdStr
      + " from pid file " + pidFilePath);
  int sleepCounter = 0;
  final int sleepInterval = 100;

  // loop waiting for pid file to show up 
  // until either the completed flag is set which means something bad 
  // happened or our timer expires in which case we admit defeat
  while (!completed.get()) {
    processId = ProcessIdFileReader.getProcessId(pidFilePath);
    if (processId != null) {
      LOG.debug("Got pid " + processId + " for container "
          + containerIdStr);
      break;
    }
    else if ((sleepCounter*sleepInterval) > maxKillWaitTime) {
      LOG.info("Could not get pid for " + containerIdStr
      		+ ". Waited for " + maxKillWaitTime + " ms.");
      break;
    }
    else {
      ++sleepCounter;
      Thread.sleep(sleepInterval);
    }
  }
  return processId;
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:39,代码来源:ContainerLaunch.java

示例7: getContainerPid

import org.apache.hadoop.yarn.server.nodemanager.util.ProcessIdFileReader; //导入依赖的package包/类
/**
 * Loop through for a time-bounded interval waiting to
 * read the process id from a file generated by a running process.
 * @param pidFilePath File from which to read the process id
 * @return Process ID
 * @throws Exception
 */
private String getContainerPid(Path pidFilePath) throws Exception {
  String containerIdStr = 
      container.getContainerId().toString();
  String processId = null;
  LOG.debug("Accessing pid for container " + containerIdStr
      + " from pid file " + pidFilePath);
  int sleepCounter = 0;
  final int sleepInterval = 100;

  // loop waiting for pid file to show up 
  // until our timer expires in which case we admit defeat
  while (true) {
    processId = ProcessIdFileReader.getProcessId(pidFilePath);
    if (processId != null) {
      LOG.debug("Got pid " + processId + " for container "
          + containerIdStr);
      break;
    }
    else if ((sleepCounter*sleepInterval) > maxKillWaitTime) {
      LOG.info("Could not get pid for " + containerIdStr
      		+ ". Waited for " + maxKillWaitTime + " ms.");
      break;
    }
    else {
      ++sleepCounter;
      Thread.sleep(sleepInterval);
    }
  }
  return processId;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:38,代码来源:ContainerLaunch.java


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