hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject [20/50] [abbrv] hadoop git commit: HADOOP-12955. Fix bugs in the initialization of the ISA-L library JNI bindings (Kai Zheng via cmccabe)
Date Tue, 05 Apr 2016 19:30:53 GMT
HADOOP-12955. Fix bugs in the initialization of the ISA-L library JNI bindings (Kai Zheng via
cmccabe)


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

Branch: refs/heads/HDFS-1312
Commit: 19639785f5e9c483558ce585287b9dda9d626263
Parents: 12b11e2
Author: Colin Patrick Mccabe <cmccabe@cloudera.com>
Authored: Thu Mar 31 15:09:11 2016 -0700
Committer: Colin Patrick Mccabe <cmccabe@cloudera.com>
Committed: Thu Mar 31 15:09:11 2016 -0700

----------------------------------------------------------------------
 .../hadoop/util/NativeLibraryChecker.java       |  8 ++--
 .../hadoop/io/erasurecode/erasure_coder.c       |  1 +
 .../apache/hadoop/io/erasurecode/isal_load.c    | 46 +++++++++-----------
 .../apache/hadoop/io/erasurecode/isal_load.h    |  6 +--
 .../io/erasurecode/jni_erasure_code_native.c    | 11 +++--
 5 files changed, 34 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/19639785/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
index 46f0897..e166bec 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NativeLibraryChecker.java
@@ -95,12 +95,12 @@ public class NativeLibraryChecker {
         snappyLibraryName = SnappyCodec.getLibraryName();
       }
 
-      try {
-        isalDetail = ErasureCodeNative.getLoadingFailureReason();
+      isalDetail = ErasureCodeNative.getLoadingFailureReason();
+      if (isalDetail != null) {
+        isalLoaded = false;
+      } else {
         isalDetail = ErasureCodeNative.getLibraryName();
         isalLoaded = true;
-      } catch (UnsatisfiedLinkError e) {
-        isalLoaded = false;
       }
 
       openSslDetail = OpensslCipher.getLoadingFailureReason();

http://git-wip-us.apache.org/repos/asf/hadoop/blob/19639785/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/erasure_coder.c
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/erasure_coder.c
b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/erasure_coder.c
index b3479bb..b2d856b 100644
--- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/erasure_coder.c
+++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/erasure_coder.c
@@ -19,6 +19,7 @@
 #include "erasure_code.h"
 #include "gf_util.h"
 #include "erasure_coder.h"
+#include "dump.h"
 
 #include <stdio.h>
 #include <stdlib.h>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/19639785/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.c
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.c
b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.c
index 55e8efd..26d8e1a 100644
--- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.c
+++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.c
@@ -78,6 +78,12 @@ static const char* load_functions() {
 
 void load_erasurecode_lib(char* err, size_t err_len) {
   const char* errMsg;
+  const char* library = NULL;
+#ifdef UNIX
+  Dl_info dl_info;
+#else
+  LPTSTR filename = NULL;
+#endif
 
   err[0] = '\0';
 
@@ -111,38 +117,28 @@ void load_erasurecode_lib(char* err, size_t err_len) {
   if (errMsg != NULL) {
     snprintf(err, err_len, "Loading functions from ISA-L failed: %s", errMsg);
   }
-}
 
-int build_support_erasurecode() {
-#ifdef HADOOP_ISAL_LIBRARY
-  return 1;
-#else
-  return 0;
-#endif
-}
-
-const char* get_library_name() {
 #ifdef UNIX
-  Dl_info dl_info;
-
-  if (isaLoader->ec_encode_data == NULL) {
-    return HADOOP_ISAL_LIBRARY;
-  }
-
   if(dladdr(isaLoader->ec_encode_data, &dl_info)) {
-    return dl_info.dli_fname;
+    library = dl_info.dli_fname;
   }
 #else
-  LPTSTR filename = NULL;
-
-  if (isaLoader->libec == NULL) {
-    return HADOOP_ISAL_LIBRARY;
-  }
-
   if (GetModuleFileName(isaLoader->libec, filename, 256) > 0) {
-    return filename;
+    library = filename;
   }
 #endif
 
-  return NULL;
+  if (library == NULL) {
+    library = HADOOP_ISAL_LIBRARY;
+  }
+
+  isaLoader->libname = strdup(library);
 }
+
+int build_support_erasurecode() {
+#ifdef HADOOP_ISAL_LIBRARY
+  return 1;
+#else
+  return 0;
+#endif
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/hadoop/blob/19639785/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.h
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.h
b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.h
index 635706d..7cb7a6a 100644
--- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.h
+++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/isal_load.h
@@ -78,6 +78,7 @@ typedef void (__cdecl *__d_ec_encode_data_update)(int, int, int, int, unsigned
c
 typedef struct __IsaLibLoader {
   // The loaded library handle
   void* libec;
+  char* libname;
 
   __d_gf_mul gf_mul;
   __d_gf_inv gf_inv;
@@ -134,11 +135,6 @@ static FARPROC WINAPI myDlsym(HMODULE handle, LPCSTR symbol) {
 int build_support_erasurecode();
 
 /**
- * Get the library name possibly of full path.
- */
-const char* get_library_name();
-
-/**
  * Initialize and load erasure code library, returning error message if any.
  *
  * @param err     The err message buffer.

http://git-wip-us.apache.org/repos/asf/hadoop/blob/19639785/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_erasure_code_native.c
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_erasure_code_native.c
b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_erasure_code_native.c
index eb09e73..b46e8a9 100644
--- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_erasure_code_native.c
+++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_erasure_code_native.c
@@ -22,6 +22,7 @@
 
 #include "org_apache_hadoop.h"
 #include "jni_common.h"
+#include "isal_load.h"
 #include "org_apache_hadoop_io_erasurecode_ErasureCodeNative.h"
 
 #ifdef UNIX
@@ -37,9 +38,11 @@ Java_org_apache_hadoop_io_erasurecode_ErasureCodeNative_loadLibrary
 JNIEXPORT jstring JNICALL
 Java_org_apache_hadoop_io_erasurecode_ErasureCodeNative_getLibraryName
 (JNIEnv *env, jclass myclass) {
-  char* libName = get_library_name();
-  if (libName == NULL) {
-    libName = "Unavailable";
+  if (isaLoader == NULL) {
+    THROW(env, "java/lang/UnsatisfiedLinkError",
+                             "Unavailable: library not loaded yet");
+    return (jstring)NULL;
   }
-  return (*env)->NewStringUTF(env, libName);
+
+  return (*env)->NewStringUTF(env, isaLoader->libname);
 }


Mime
View raw message