You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/10 01:16:50 UTC

[3/9] incubator-slider git commit: SLIDER-622 move test-side native lib checks into SliderUtils for AM to use too

SLIDER-622 move test-side native lib checks into SliderUtils for AM to use too


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/e4df15af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/e4df15af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/e4df15af

Branch: refs/heads/develop
Commit: e4df15af3440957a407fd237ee91b8faf5525b6f
Parents: 152c9cb
Author: Steve Loughran <st...@apache.org>
Authored: Sun Nov 9 18:53:36 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Mon Nov 10 00:09:17 2014 +0000

----------------------------------------------------------------------
 .../apache/slider/common/tools/SliderUtils.java | 52 ++++++++++++++------
 .../tools/TestExecutionEnvironment.groovy       |  2 +-
 .../common/tools/TestWindowsSupport.groovy      |  2 +-
 .../apache/slider/test/SliderTestUtils.groovy   | 38 ++------------
 4 files changed, 41 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e4df15af/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
index 1a9b8fb..247c25d 100644
--- a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
+++ b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.DFSConfigKeys;
 import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.io.nativeio.NativeIO;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.SecurityUtil;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -1720,6 +1721,36 @@ public final class SliderUtils {
     return is;
   }
 
+  /**
+   * Check for any needed libraries being present. On Unix none are needed;
+   * on windows they must be present
+   * @return true if all is well
+   */
+  public static String checkForRequiredNativeLibraries() {
+
+    if (!Shell.WINDOWS) {
+      return "";
+    }
+    StringBuilder errorText = new StringBuilder("");
+    if (!NativeIO.isAvailable()) {
+      errorText.append("No native IO library. ");
+    }
+    try {
+      String path = Shell.getQualifiedBinPath("winutils.exe");
+      log.debug("winutils is at {}", path);
+    } catch (IOException e) {
+      errorText.append("No WINUTILS.EXE. ");
+      log.warn("No winutils: {}", e, e);
+    }
+    try {
+      File target = new File("target");
+      FileUtil.canRead(target);
+    } catch (UnsatisfiedLinkError e) {
+      log.warn("Failing to link to native IO methods: {}", e, e);
+      errorText.append("No native IO methods");
+    }
+    return errorText.toString();
+  }
 
   /**
    * Strictly verify that windows utils is present.
@@ -1727,25 +1758,14 @@ public final class SliderUtils {
    * the headers. 
    * @throws IOException on any problem reading the file
    * @throws FileNotFoundException if the file is not considered valid
-   * @param logger
    */
-  public static void maybeVerifyWinUtilsValid(Logger logger) throws
+  public static void maybeVerifyWinUtilsValid() throws
       IOException,
       SliderException {
-    if (!Shell.WINDOWS) {
-      return;
-    }
-    String exePath = Shell.getWinUtilsPath();
-    String program = WINUTILS;
-    if (exePath == null) {
-      throw new FileNotFoundException(program + " not found on Path : " +
-                                      System.getenv("Path"));
+    String errorText = SliderUtils.checkForRequiredNativeLibraries();
+    if (!errorText.isEmpty()) {
+      throw new BadClusterStateException(errorText);
     }
-    File exe = new File(exePath);
-
-    verifyWindowsExe(program, exe);
-    execCommand(WINUTILS, 0, 5000, log, null, exePath, "systeminfo");
-
   }
 
   public static void verifyIsFile(String program, File exe) throws
@@ -1947,7 +1967,7 @@ public final class SliderUtils {
   public static void validateSliderClientEnvironment(Logger logger) throws
       IOException,
       SliderException {
-    maybeVerifyWinUtilsValid(logger);
+    maybeVerifyWinUtilsValid();
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e4df15af/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy
index ad78c0e..97b72d1 100644
--- a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestExecutionEnvironment.groovy
@@ -34,7 +34,7 @@ class TestExecutionEnvironment extends SliderTestBase {
 
   @Test
   public void testWinutils() throws Throwable {
-    SliderUtils.maybeVerifyWinUtilsValid(log);
+    SliderUtils.maybeVerifyWinUtilsValid();
 
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e4df15af/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
index 61960e6..6351c14 100644
--- a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestWindowsSupport.groovy
@@ -134,7 +134,7 @@ class TestWindowsSupport extends SliderTestBase {
   @Test
   public void testHasWinutils() throws Throwable {
     assume(Shell.WINDOWS, "not windows")
-    SliderUtils.maybeVerifyWinUtilsValid(log)
+    SliderUtils.maybeVerifyWinUtilsValid()
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/e4df15af/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
index 6e63da9..87621a1 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestUtils.groovy
@@ -27,9 +27,7 @@ import org.apache.commons.httpclient.methods.GetMethod
 import org.apache.hadoop.conf.Configuration
 import org.apache.hadoop.fs.FileStatus
 import org.apache.hadoop.fs.FileSystem as HadoopFS
-import org.apache.hadoop.fs.FileUtil
 import org.apache.hadoop.fs.Path
-import org.apache.hadoop.io.nativeio.NativeIO
 import org.apache.hadoop.util.Shell
 import org.apache.hadoop.yarn.api.records.ApplicationReport
 import org.apache.hadoop.yarn.conf.YarnConfiguration
@@ -191,45 +189,15 @@ class SliderTestUtils extends Assert {
     fail("Not implemented")
   }
 
-  /**
-   * Check for any needed libraries being present. On Unix none are needed;
-   * on windows they must be present
-   * @return true if all is well
-   */
-  public static String checkForRequiredLibraries() {
-    
-    if (!Shell.WINDOWS) {
-      return "";
-    }
-    StringBuilder errorText = new StringBuilder("")
-    boolean available = true;
-    if (!NativeIO.available) {
-      errorText.append("No native IO library. ")
-    }
-    try {
-      def path = Shell.getQualifiedBinPath("winutils.exe");
-      log.debug("winutils is at $path")
-    } catch (IOException e) {
-      errorText.append("No WINUTILS.EXE. ")
-      log.warn("No winutils: $e", e)
-    }
-    try {
-      File target = new File("target")
-      FileUtil.canRead(target)
-    } catch (UnsatisfiedLinkError e) {
-      log.warn("Failing to link to native IO methods: $e", e)
-      errorText.append("No native IO methods")
-    }
-    return errorText.toString();
-  }
+
 
   /**
    * Assert that any needed libraries being present. On Unix none are needed;
    * on windows they must be present
    */
   public static void assertNativeLibrariesPresent() {
-    String errorText = checkForRequiredLibraries()
-    if (errorText != null) {
+    String errorText = SliderUtils.checkForRequiredNativeLibraries()
+    if (errorText != "") {
       fail(errorText)
     }
   }