hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1504711 - in /hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common: ./ src/main/java/org/apache/hadoop/io/compress/ src/main/java/org/apache/hadoop/io/compress/bzip2/ src/main/java/org/apache/hadoop/io/compress/lz4/ s...
Date Thu, 18 Jul 2013 22:52:28 GMT
Author: llu
Date: Thu Jul 18 22:52:28 2013
New Revision: 1504711

URL: http://svn.apache.org/r1504711
Log:
HADOOP-9164. Print paths of loaded native libraries in NativeLibraryChecker. (Binglin Chang
via llu)

Modified:
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/Lz4Codec.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/SnappyCodec.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Factory.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/lz4/Lz4Compressor.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/snappy/SnappyCompressor.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibCompressor.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibFactory.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeCodeLoader.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.c
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCodeLoader.c
    hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/CHANGES.txt
Thu Jul 18 22:52:28 2013
@@ -63,6 +63,9 @@ Release 2.1.0-beta - 2013-07-02
 
   IMPROVEMENTS
 
+    HADOOP-9164. Print paths of loaded native libraries in
+    NativeLibraryChecker. (Binglin Chang via llu)
+
     HADOOP-9253. Capture ulimit info in the logs at service start time.
     (Arpit Gupta via suresh)
 

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/Lz4Codec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/Lz4Codec.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/Lz4Codec.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/Lz4Codec.java
Thu Jul 18 22:52:28 2013
@@ -69,6 +69,10 @@ public class Lz4Codec implements Configu
     return NativeCodeLoader.isNativeCodeLoaded();
   }
 
+  public static String getLibraryName() {
+    return Lz4Compressor.getLibraryName();
+  }
+
   /**
    * Create a {@link CompressionOutputStream} that will write to the given
    * {@link OutputStream}.

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/SnappyCodec.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/SnappyCodec.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/SnappyCodec.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/SnappyCodec.java
Thu Jul 18 22:52:28 2013
@@ -79,6 +79,10 @@ public class SnappyCodec implements Conf
         SnappyDecompressor.isNativeCodeLoaded();
   }
 
+  public static String getLibraryName() {
+    return SnappyCompressor.getLibraryName();
+  }
+
   /**
    * Create a {@link CompressionOutputStream} that will write to the given
    * {@link OutputStream}.

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.java
Thu Jul 18 22:52:28 2013
@@ -298,4 +298,6 @@ public class Bzip2Compressor implements 
   private native static long getBytesRead(long strm);
   private native static long getBytesWritten(long strm);
   private native static void end(long strm);
+
+  public native static String getLibraryName();
 }

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Factory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Factory.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Factory.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/bzip2/Bzip2Factory.java
Thu Jul 18 22:52:28 2013
@@ -78,6 +78,14 @@ public class Bzip2Factory {
     return nativeBzip2Loaded;
   }
 
+  public static String getLibraryName(Configuration conf) {
+    if (isNativeBzip2Loaded(conf)) {
+      return Bzip2Compressor.getLibraryName();
+    } else {
+      return bzip2LibraryName;
+    }
+  }
+
   /**
    * Return the appropriate type of the bzip2 compressor. 
    * 

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/lz4/Lz4Compressor.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/lz4/Lz4Compressor.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/lz4/Lz4Compressor.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/lz4/Lz4Compressor.java
Thu Jul 18 22:52:28 2013
@@ -296,4 +296,6 @@ public class Lz4Compressor implements Co
   private native static void initIDs();
 
   private native int compressBytesDirect();
+
+  public native static String getLibraryName();
 }

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/snappy/SnappyCompressor.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/snappy/SnappyCompressor.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/snappy/SnappyCompressor.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/snappy/SnappyCompressor.java
Thu Jul 18 22:52:28 2013
@@ -298,4 +298,6 @@ public class SnappyCompressor implements
   private native static void initIDs();
 
   private native int compressBytesDirect();
+
+  public native static String getLibraryName();
 }

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibCompressor.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibCompressor.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibCompressor.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibCompressor.java
Thu Jul 18 22:52:28 2013
@@ -444,4 +444,6 @@ public class ZlibCompressor implements C
   private native static long getBytesWritten(long strm);
   private native static void reset(long strm);
   private native static void end(long strm);
+
+  public native static String getLibraryName();
 }

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibFactory.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibFactory.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibFactory.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/zlib/ZlibFactory.java
Thu Jul 18 22:52:28 2013
@@ -65,7 +65,11 @@ public class ZlibFactory {
                           CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, 
                           CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_DEFAULT);
   }
-  
+
+  public static String getLibraryName() {
+    return ZlibCompressor.getLibraryName();
+  }
+
   /**
    * Return the appropriate type of the zlib compressor. 
    * 

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeCodeLoader.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeCodeLoader.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeCodeLoader.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeCodeLoader.java
Thu Jul 18 22:52:28 2013
@@ -79,6 +79,8 @@ public class NativeCodeLoader {
    */
   public static native boolean buildSupportsSnappy();
 
+  public static native String getLibraryName();
+
   /**
    * Return if native hadoop libraries, if present, can be used for this job.
    * @param conf configuration

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
Thu Jul 18 22:52:28 2013
@@ -20,7 +20,9 @@ package org.apache.hadoop.util;
 
 import org.apache.hadoop.util.NativeCodeLoader;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.compress.Lz4Codec;
 import org.apache.hadoop.io.compress.SnappyCodec;
+import org.apache.hadoop.io.compress.bzip2.Bzip2Factory;
 import org.apache.hadoop.io.compress.zlib.ZlibFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
@@ -35,7 +37,7 @@ public class NativeLibraryChecker {
     String usage = "NativeLibraryChecker [-a|-h]\n"
         + "  -a  use -a to check all libraries are available\n"
         + "      by default just check hadoop library is available\n"
-        + "      exit with error code if check failed\n"
+        + "      exit with error code 1 if check failed\n"
         + "  -h  print this message\n";
     if (args.length > 1 ||
         (args.length == 1 &&
@@ -51,23 +53,44 @@ public class NativeLibraryChecker {
       }
       checkAll = true;
     }
+    Configuration conf = new Configuration();
     boolean nativeHadoopLoaded = NativeCodeLoader.isNativeCodeLoaded();
     boolean zlibLoaded = false;
     boolean snappyLoaded = false;
     // lz4 is linked within libhadoop
     boolean lz4Loaded = nativeHadoopLoaded;
+    boolean bzip2Loaded = Bzip2Factory.isNativeBzip2Loaded(conf);
+    String hadoopLibraryName = "";
+    String zlibLibraryName = "";
+    String snappyLibraryName = "";
+    String lz4LibraryName = "";
+    String bzip2LibraryName = "";
     if (nativeHadoopLoaded) {
-      zlibLoaded = ZlibFactory.isNativeZlibLoaded(new Configuration());
+      hadoopLibraryName = NativeCodeLoader.getLibraryName();
+      zlibLoaded = ZlibFactory.isNativeZlibLoaded(conf);
+      if (zlibLoaded) {
+        zlibLibraryName = ZlibFactory.getLibraryName();
+      }
       snappyLoaded = NativeCodeLoader.buildSupportsSnappy() &&
           SnappyCodec.isNativeCodeLoaded();
+      if (snappyLoaded && NativeCodeLoader.buildSupportsSnappy()) {
+        snappyLibraryName = SnappyCodec.getLibraryName();
+      }
+      if (lz4Loaded) {
+        lz4LibraryName = Lz4Codec.getLibraryName();
+      }
+      if (bzip2Loaded) {
+        bzip2LibraryName = Bzip2Factory.getLibraryName(conf);
+      }
     }
     System.out.println("Native library checking:");
-    System.out.printf("hadoop: %b\n", nativeHadoopLoaded);
-    System.out.printf("zlib:   %b\n", zlibLoaded);
-    System.out.printf("snappy: %b\n", snappyLoaded);
-    System.out.printf("lz4:    %b\n", lz4Loaded);
+    System.out.printf("hadoop: %b %s\n", nativeHadoopLoaded, hadoopLibraryName);
+    System.out.printf("zlib:   %b %s\n", zlibLoaded, zlibLibraryName);
+    System.out.printf("snappy: %b %s\n", snappyLoaded, snappyLibraryName);
+    System.out.printf("lz4:    %b %s\n", lz4Loaded, lz4LibraryName);
+    System.out.printf("bzip2:  %b %s\n", bzip2Loaded, bzip2LibraryName);
     if ((!nativeHadoopLoaded) ||
-        (checkAll && !(zlibLoaded && snappyLoaded && lz4Loaded)))
{
+        (checkAll && !(zlibLoaded && snappyLoaded && lz4Loaded &&
bzip2Loaded))) {
       // return 1 to indicated check failed
       ExitUtil.terminate(1);
     }

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.c?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.c
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/bzip2/Bzip2Compressor.c
Thu Jul 18 22:52:28 2013
@@ -239,6 +239,21 @@ Java_org_apache_hadoop_io_compress_bzip2
     }
 }
 
+JNIEXPORT jstring JNICALL
+Java_org_apache_hadoop_io_compress_bzip2_Bzip2Compressor_getLibraryName(JNIEnv *env, jclass
class) {
+#ifdef UNIX
+  if (dlsym_BZ2_bzCompress) {
+    Dl_info dl_info;
+    if(dladdr(
+        dlsym_BZ2_bzCompress,
+        &dl_info)) {
+      return (*env)->NewStringUTF(env, dl_info.dli_fname);
+    }
+  }
+#endif
+  return (*env)->NewStringUTF(env, HADOOP_BZIP2_LIBRARY);
+}
+
 /**
  * vim: sw=2: ts=2: et:
  */

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
Thu Jul 18 22:52:28 2013
@@ -103,3 +103,9 @@ JNIEXPORT jint JNICALL Java_org_apache_h
   return (jint)compressed_direct_buf_len;
 }
 
+JNIEXPORT jstring JNICALL
+Java_org_apache_hadoop_io_compress_lz4_Lz4Compressor_getLibraryName(
+ JNIEnv *env, jclass class
+ ) {
+  return (*env)->NewStringUTF(env, "revision:43");
+}

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
Thu Jul 18 22:52:28 2013
@@ -117,4 +117,19 @@ JNIEXPORT jint JNICALL Java_org_apache_h
   return (jint)buf_len;
 }
 
+JNIEXPORT jstring JNICALL
+Java_org_apache_hadoop_io_compress_snappy_SnappyCompressor_getLibraryName(JNIEnv *env, jclass
class) {
+#ifdef UNIX
+  if (dlsym_snappy_compress) {
+    Dl_info dl_info;
+    if(dladdr(
+        dlsym_snappy_compress,
+        &dl_info)) {
+      return (*env)->NewStringUTF(env, dl_info.dli_fname);
+    }
+  }
+#endif
+  return (*env)->NewStringUTF(env, HADOOP_SNAPPY_LIBRARY);
+}
+
 #endif //define HADOOP_SNAPPY_LIBRARY

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
Thu Jul 18 22:52:28 2013
@@ -367,6 +367,21 @@ Java_org_apache_hadoop_io_compress_zlib_
     }
 }
 
+JNIEXPORT jstring JNICALL
+Java_org_apache_hadoop_io_compress_zlib_ZlibCompressor_getLibraryName(JNIEnv *env, jclass
class) {
+#ifdef UNIX
+  if (dlsym_deflateInit2_) {
+    Dl_info dl_info;
+    if(dladdr(
+        dlsym_deflateInit2_,
+        &dl_info)) {
+      return (*env)->NewStringUTF(env, dl_info.dli_fname);
+    }
+  }
+#endif
+  return (*env)->NewStringUTF(env, HADOOP_ZLIB_LIBRARY);
+}
+
 /**
  * vim: sw=2: ts=2: et:
  */

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCodeLoader.c
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCodeLoader.c?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCodeLoader.c
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCodeLoader.c
Thu Jul 18 22:52:28 2013
@@ -19,6 +19,7 @@
 #include "org_apache_hadoop.h"
 
 #ifdef UNIX
+#include <dlfcn.h>
 #include "config.h"
 #endif // UNIX
 
@@ -32,4 +33,14 @@ JNIEXPORT jboolean JNICALL Java_org_apac
 #else
   return JNI_FALSE;
 #endif
-}
\ No newline at end of file
+}
+
+JNIEXPORT jstring JNICALL Java_org_apache_hadoop_util_NativeCodeLoader_getLibraryName
+  (JNIEnv *env, jclass clazz)
+{
+  Dl_info dl_info;
+  int ret = dladdr(
+      Java_org_apache_hadoop_util_NativeCodeLoader_getLibraryName,
+      &dl_info);
+  return (*env)->NewStringUTF(env, ret==0 ? "Unavailable" : dl_info.dli_fname);
+}

Modified: hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java?rev=1504711&r1=1504710&r2=1504711&view=diff
==============================================================================
--- hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java
(original)
+++ hadoop/common/branches/branch-2.1-beta/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java
Thu Jul 18 22:52:28 2013
@@ -22,6 +22,9 @@ import static org.junit.Assert.*;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.io.compress.Lz4Codec;
+import org.apache.hadoop.io.compress.SnappyCodec;
+import org.apache.hadoop.io.compress.zlib.ZlibFactory;
 import org.apache.hadoop.util.NativeCodeLoader;
 
 public class TestNativeCodeLoader {
@@ -44,6 +47,14 @@ public class TestNativeCodeLoader {
       fail("TestNativeCodeLoader: libhadoop.so testing was required, but " +
           "libhadoop.so was not loaded.");
     }
+    assertFalse(NativeCodeLoader.getLibraryName().isEmpty());
+    // library names are depended on platform and build envs
+    // so just check names are available
+    assertFalse(ZlibFactory.getLibraryName().isEmpty());
+    if (NativeCodeLoader.buildSupportsSnappy()) {
+      assertFalse(SnappyCodec.getLibraryName().isEmpty());
+    }
+    assertFalse(Lz4Codec.getLibraryName().isEmpty());
     LOG.info("TestNativeCodeLoader: libhadoop.so is loaded.");
   }
 }



Mime
View raw message