WIP: Minimizing dependencies in HadoopClassLoader to simplify it's move to core 
module.


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

Branch: refs/heads/ignite-3912
Commit: b4c91424726ed92e3d1020cf0c127661dc084bc2
Parents: 38cb590
Author: vozerov-gridgain <voze...@gridgain.com>
Authored: Fri Sep 16 11:10:01 2016 +0300
Committer: vozerov-gridgain <voze...@gridgain.com>
Committed: Fri Sep 16 11:10:01 2016 +0300

----------------------------------------------------------------------
 .../processors/hadoop/HadoopClassLoader.java    | 31 +++++++++++++-------
 .../processors/hadoop/v2/HadoopV2Job.java       |  2 +-
 2 files changed, 22 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b4c91424/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
----------------------------------------------------------------------
diff --git 
a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
 
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
index 2e0e271..1e78f65 100644
--- 
a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
+++ 
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopClassLoader.java
@@ -31,10 +31,7 @@ import java.util.Vector;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import org.apache.hadoop.util.NativeCodeLoader;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.hadoop.v2.HadoopDaemon;
-import 
org.apache.ignite.internal.processors.hadoop.v2.HadoopShutdownHookManager;
 import org.apache.ignite.internal.util.ClassCache;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -66,8 +63,21 @@ public class HadoopClassLoader extends URLClassLoader 
implements ClassCache {
         registerAsParallelCapable();
     }
 
-    /** Name of the Hadoop daemon class. */
-    public static final String HADOOP_DAEMON_CLASS_NAME = 
"org.apache.hadoop.util.Daemon";
+    /** Hadoop class name: Daemon. */
+    public static final String CLS_DAEMON = "org.apache.hadoop.util.Daemon";
+
+    /** Hadoop class name: ShutdownHookManager. */
+    public static final String CLS_SHUTDOWN_HOOK_MANAGER = 
"org.apache.hadoop.util.ShutdownHookManager";
+
+    /** Hadoop class name: NativeCodeLoader. */
+    public static final String CLS_NATIVE_CODE_LOADER = 
"org.apache.hadoop.util.NativeCodeLoader";
+
+    /** Hadoop class name: Daemon replacement. */
+    public static final String CLS_DAEMON_REPLACE = 
"org.apache.ignite.internal.processors.hadoop.v2.HadoopDaemon";
+
+    /** Hadoop class name: ShutdownHookManager replacement. */
+    public static final String CLS_SHUTDOWN_HOOK_MANAGER_REPLACE =
+        
"org.apache.ignite.internal.processors.hadoop.v2.HadoopShutdownHookManager";
 
     /** Name of libhadoop library. */
     private static final String LIBHADOOP = "hadoop.";
@@ -152,7 +162,8 @@ public class HadoopClassLoader extends URLClassLoader 
implements ClassCache {
     private void initializeNativeLibraries() {
         try {
             // This must trigger native library load.
-            Class.forName(NativeCodeLoader.class.getName(), true, APP_CLS_LDR);
+            // TODO: Do not delegate to APP LDR
+            Class.forName(CLS_NATIVE_CODE_LOADER, true, APP_CLS_LDR);
 
             final Vector<Object> curVector = U.field(this, "nativeLibraries");
 
@@ -221,12 +232,12 @@ public class HadoopClassLoader extends URLClassLoader 
implements ClassCache {
     @Override protected Class<?> loadClass(String name, boolean resolve) 
throws ClassNotFoundException {
         try {
             if (isHadoop(name)) { // Always load Hadoop classes explicitly, 
since Hadoop can be available in App classpath.
-                if (name.endsWith(".util.ShutdownHookManager"))  // Dirty hack 
to get rid of Hadoop shutdown hooks.
-                    return loadFromBytes(name, 
HadoopShutdownHookManager.class.getName());
-                else if (name.equals(HADOOP_DAEMON_CLASS_NAME))
+                if (name.equals(CLS_SHUTDOWN_HOOK_MANAGER))  // Dirty hack to 
get rid of Hadoop shutdown hooks.
+                    return loadFromBytes(name, 
CLS_SHUTDOWN_HOOK_MANAGER_REPLACE);
+                else if (name.equals(CLS_DAEMON))
                     // We replace this in order to be able to forcibly stop 
some daemon threads
                     // that otherwise never stop (e.g. PeerCache runnables):
-                    return loadFromBytes(name, HadoopDaemon.class.getName());
+                    return loadFromBytes(name, CLS_DAEMON_REPLACE);
 
                 return loadClassExplicitly(name, resolve);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b4c91424/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Job.java
----------------------------------------------------------------------
diff --git 
a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Job.java
 
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Job.java
index a0f30eb..595474c 100644
--- 
a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Job.java
+++ 
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Job.java
@@ -382,7 +382,7 @@ public class HadoopV2Job implements HadoopJob {
      * @throws Exception On error.
      */
     private void stopHadoopFsDaemons(ClassLoader ldr) throws Exception {
-        Class<?> daemonCls = 
ldr.loadClass(HadoopClassLoader.HADOOP_DAEMON_CLASS_NAME);
+        Class<?> daemonCls = ldr.loadClass(HadoopClassLoader.CLS_DAEMON);
 
         Method m = daemonCls.getMethod("dequeueAndStopAll");
 

Reply via email to