You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ac...@apache.org on 2012/08/30 04:27:51 UTC
svn commit: r1378792 - in /hadoop/common/branches/branch-1-win: ./
src/core/org/apache/hadoop/util/ src/test/org/apache/hadoop/util/
src/winutils/
Author: acmurthy
Date: Thu Aug 30 02:27:50 2012
New Revision: 1378792
URL: http://svn.apache.org/viewvc?rev=1378792&view=rev
Log:
MAPREDUCE-4510. Fix needless check/logging of getconf in Windows. Contributed by Bikas Saha.
Modified:
hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcfsBasedProcessTree.java
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java
hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/WindowsBasedProcessTree.java
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestProcfsBasedProcessTree.java
hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestWindowsBasedProcessTree.java
hadoop/common/branches/branch-1-win/src/winutils/main.c
Modified: hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt (original)
+++ hadoop/common/branches/branch-1-win/CHANGES.branch-1-win.txt Thu Aug 30 02:27:50 2012
@@ -66,6 +66,9 @@ branch-hadoop-1-win - unreleased
MAPREDUCE-4598. Add support for NodeHealthCheck script for Windows. (Bikas
Saha via acmurthy)
+ MAPREDUCE-4510. Fix needless check/logging of getconf in Windows. (Bikas
+ Saha via acmurthy)
+
BUG FIXES
HDFS-6527. Backport HADOOP-7389: Use of TestingGroups by tests causes
Modified: hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java (original)
+++ hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcessTree.java Thu Aug 30 02:27:50 2012
@@ -56,10 +56,11 @@ public class ProcessTree {
if (Shell.WINDOWS) {
ShellCommandExecutor shexec = null;
try {
- String args[] = {Shell.WINUTILS};
+ String args[] = {Shell.WINUTILS, "help"};
shexec = new ShellCommandExecutor(args);
shexec.execute();
} catch (IOException e) {
+ LOG.error(StringUtils.stringifyException(e));
} finally {
String result = shexec.getOutput();
if (result == null
Modified: hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcfsBasedProcessTree.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcfsBasedProcessTree.java?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcfsBasedProcessTree.java (original)
+++ hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/ProcfsBasedProcessTree.java Thu Aug 30 02:27:50 2012
@@ -53,32 +53,30 @@ public class ProcfsBasedProcessTree exte
static final String PROCFS_STAT_FILE = "stat";
static final String PROCFS_CMDLINE_FILE = "cmdline";
public static final long PAGE_SIZE;
- static {
- ShellCommandExecutor shellExecutor =
- new ShellCommandExecutor(new String[]{"getconf", "PAGESIZE"});
- long pageSize = -1;
- try {
- shellExecutor.execute();
- pageSize = Long.parseLong(shellExecutor.getOutput().replace("\n", ""));
- } catch (IOException e) {
- LOG.error(StringUtils.stringifyException(e));
- } finally {
- PAGE_SIZE = pageSize;
- }
- }
public static final long JIFFY_LENGTH_IN_MILLIS; // in millisecond
+
static {
- ShellCommandExecutor shellExecutor =
- new ShellCommandExecutor(new String[]{"getconf", "CLK_TCK"});
long jiffiesPerSecond = -1;
+ long pageSize = -1;
try {
- shellExecutor.execute();
- jiffiesPerSecond = Long.parseLong(shellExecutor.getOutput().replace("\n", ""));
+ if(Shell.LINUX) {
+ ShellCommandExecutor shellExecutorClk = new ShellCommandExecutor(
+ new String[] { "getconf", "CLK_TCK" });
+ shellExecutorClk.execute();
+ jiffiesPerSecond = Long.parseLong(shellExecutorClk.getOutput().replace("\n", ""));
+
+ ShellCommandExecutor shellExecutorPage = new ShellCommandExecutor(
+ new String[] { "getconf", "PAGESIZE" });
+ shellExecutorPage.execute();
+ pageSize = Long.parseLong(shellExecutorPage.getOutput().replace("\n", ""));
+
+ }
} catch (IOException e) {
LOG.error(StringUtils.stringifyException(e));
} finally {
JIFFY_LENGTH_IN_MILLIS = jiffiesPerSecond != -1 ?
Math.round(1000D / jiffiesPerSecond) : -1;
+ PAGE_SIZE = pageSize;
}
}
@@ -110,9 +108,8 @@ public class ProcfsBasedProcessTree exte
*/
public static boolean isAvailable() {
try {
- String osName = System.getProperty("os.name");
- if (!osName.startsWith("Linux")) {
- LOG.info("ProcfsBasedProcessTree currently is supported only on "
+ if (!Shell.LINUX) {
+ LOG.debug("ProcfsBasedProcessTree currently is supported only on "
+ "Linux.");
return false;
}
Modified: hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java (original)
+++ hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/Shell.java Thu Aug 30 02:27:50 2012
@@ -183,8 +183,11 @@ abstract public class Shell {
}
/** Set to true on Windows platforms */
- public static final boolean WINDOWS /* borrowed from Path.WINDOWS */
+ public static final boolean WINDOWS
= System.getProperty("os.name").startsWith("Windows");
+
+ public static final boolean LINUX
+ = System.getProperty("os.name").startsWith("Linux");
/* Set flag for aiding Windows porting temporarily for branch-1-win*/
// TODO - this needs to be fixed
Modified: hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/WindowsBasedProcessTree.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/WindowsBasedProcessTree.java?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/WindowsBasedProcessTree.java (original)
+++ hadoop/common/branches/branch-1-win/src/core/org/apache/hadoop/util/WindowsBasedProcessTree.java Thu Aug 30 02:27:50 2012
@@ -45,9 +45,24 @@ public class WindowsBasedProcessTree ext
private long cpuTimeMs = 0;
private Map<String, ProcessInfo> processTree =
new HashMap<String, ProcessInfo>();
-
+
public static boolean isAvailable() {
- return Shell.WINDOWS;
+ if (Shell.WINDOWS) {
+ ShellCommandExecutor shellExecutor = new ShellCommandExecutor(
+ new String[] { Shell.WINUTILS, "help" });
+ try {
+ shellExecutor.execute();
+ } catch (IOException e) {
+ LOG.error(StringUtils.stringifyException(e));
+ } finally {
+ String output = shellExecutor.getOutput();
+ if (output != null &&
+ output.contains("Prints to stdout a list of processes in the task")) {
+ return true;
+ }
+ }
+ }
+ return false;
}
public WindowsBasedProcessTree(String pid) {
Modified: hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestProcfsBasedProcessTree.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestProcfsBasedProcessTree.java?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestProcfsBasedProcessTree.java (original)
+++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestProcfsBasedProcessTree.java Thu Aug 30 02:27:50 2012
@@ -96,14 +96,17 @@ public class TestProcfsBasedProcessTree
public void testProcessTree() {
+ if (!Shell.LINUX) {
+ System.out
+ .println("ProcfsBasedProcessTree is not available on this system. Not testing");
+ return;
+
+ }
try {
- if (!ProcfsBasedProcessTree.isAvailable()) {
- System.out
- .println("ProcfsBasedProcessTree is not available on this system. Not testing");
- return;
- }
+ assertTrue(ProcfsBasedProcessTree.isAvailable());
} catch (Exception e) {
LOG.info(StringUtils.stringifyException(e));
+ assertTrue("ProcfsBaseProcessTree should be available on Linux", false);
return;
}
// create shell script
Modified: hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestWindowsBasedProcessTree.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestWindowsBasedProcessTree.java?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestWindowsBasedProcessTree.java (original)
+++ hadoop/common/branches/branch-1-win/src/test/org/apache/hadoop/util/TestWindowsBasedProcessTree.java Thu Aug 30 02:27:50 2012
@@ -39,10 +39,13 @@ public class TestWindowsBasedProcessTree
}
public void testTree() {
- if(!WindowsBasedProcessTree.isAvailable()) {
- LOG.info("WindowsBasedProcessTree not available on this platform. Not testing");
- return;
+ if( !Shell.WINDOWS) {
+ LOG.info("Platform not Windows. Not testing");
+ return;
}
+ assertTrue("WindowsBasedProcessTree should be available on Windows",
+ WindowsBasedProcessTree.isAvailable());
+
WindowsBasedProcessTreeTester pTree = new WindowsBasedProcessTreeTester("-1");
pTree.infoStr = "3524,1024,1024,500\r\n2844,1024,1024,500\r\n";
Modified: hadoop/common/branches/branch-1-win/src/winutils/main.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-1-win/src/winutils/main.c?rev=1378792&r1=1378791&r2=1378792&view=diff
==============================================================================
--- hadoop/common/branches/branch-1-win/src/winutils/main.c (original)
+++ hadoop/common/branches/branch-1-win/src/winutils/main.c Thu Aug 30 02:27:50 2012
@@ -59,6 +59,11 @@ int wmain(int argc, wchar_t* argv[])
{
return SystemInfo();
}
+ else if (wcscmp(L"help", cmd) == 0)
+ {
+ Usage(argv[0]);
+ return EXIT_SUCCESS;
+ }
else
{
Usage(argv[0]);