本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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();
}
}
}
示例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();
}
}
}
示例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;
}
示例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;
}