accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject git commit: I jumped the gun
Date Tue, 29 Oct 2013 17:27:18 GMT
Updated Branches:
  refs/heads/master 2f5974ca6 -> fb25913c5


I jumped the gun

Revert "ACCUMULO-1514 Dynamic classloader now has same behavior as general classloader"

This reverts commit 2f5974ca62ac58b07a53e021652f4b80756dc07d.


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

Branch: refs/heads/master
Commit: fb25913c5b9d1d9615dd32807b6583c558794e49
Parents: 2f5974c
Author: John Vines <jvines@gmail.com>
Authored: Tue Oct 29 13:27:08 2013 -0400
Committer: John Vines <jvines@gmail.com>
Committed: Tue Oct 29 13:27:08 2013 -0400

----------------------------------------------------------------------
 .../classloader/vfs/AccumuloVFSClassLoader.java | 119 ++++++++++---------
 1 file changed, 62 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/fb25913c/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
index b1e829a..eb653bc 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
@@ -58,9 +58,9 @@ import org.apache.log4j.Logger;
  * 
  */
 public class AccumuloVFSClassLoader {
-
+  
   public static class AccumuloVFSClassLoaderShutdownThread implements Runnable {
-
+    
     public void run() {
       try {
         AccumuloVFSClassLoader.close();
@@ -68,35 +68,35 @@ public class AccumuloVFSClassLoader {
         // do nothing, we are shutting down anyway
       }
     }
-
+    
   }
-
+  
   private static List<WeakReference<DefaultFileSystemManager>> vfsInstances =
Collections
       .synchronizedList(new ArrayList<WeakReference<DefaultFileSystemManager>>());
-
+  
   public static final String DYNAMIC_CLASSPATH_PROPERTY_NAME = "general.dynamic.classpaths";
-
+  
   public static final String DEFAULT_DYNAMIC_CLASSPATH_VALUE = "$ACCUMULO_HOME/lib/ext/[^.].*.jar\n";
-
+  
   public static final String VFS_CLASSLOADER_SYSTEM_CLASSPATH_PROPERTY = "general.vfs.classpaths";
-
+  
   public static final String VFS_CONTEXT_CLASSPATH_PROPERTY = "general.vfs.context.classpath.";
-
+  
   public static final String VFS_CACHE_DIR = "general.vfs.cache.dir";
-
+  
   private static ClassLoader parent = null;
   private static volatile ReloadingClassLoader loader = null;
   private static final Object lock = new Object();
-
+  
   private static ContextManager contextManager;
-
+  
   private static Logger log = Logger.getLogger(AccumuloVFSClassLoader.class);
-
+  
   static {
     // Register the shutdown hook
     Runtime.getRuntime().addShutdownHook(new Thread(new AccumuloVFSClassLoaderShutdownThread()));
   }
-
+  
   public synchronized static <U> Class<? extends U> loadClass(String classname,
Class<U> extension) throws ClassNotFoundException {
     try {
       return (Class<? extends U>) getClassLoader().loadClass(classname).asSubclass(extension);
@@ -104,40 +104,45 @@ public class AccumuloVFSClassLoader {
       throw new ClassNotFoundException("IO Error loading class " + classname, e);
     }
   }
-
+  
   public static Class<?> loadClass(String classname) throws ClassNotFoundException
{
     return loadClass(classname, Object.class).asSubclass(Object.class);
   }
-
+  
   static FileObject[] resolve(FileSystemManager vfs, String uris) throws FileSystemException
{
     return resolve(vfs, uris, new ArrayList<FileObject>());
   }
-
+  
   static FileObject[] resolve(FileSystemManager vfs, String uris, ArrayList<FileObject>
pathsToMonitor) throws FileSystemException {
     if (uris == null)
       return new FileObject[0];
-
+    
     ArrayList<FileObject> classpath = new ArrayList<FileObject>();
-
+    
     pathsToMonitor.clear();
-
+    
     for (String path : uris.split(",")) {
-
+      
       path = path.trim();
-
+      
       if (path.equals(""))
         continue;
-
+      
       path = AccumuloClassLoader.replaceEnvVars(path, System.getenv());
-
+      
       FileObject fo = vfs.resolveFile(path);
-
+      
       switch (fo.getType()) {
         case FILE:
-        case FOLDER:
           classpath.add(fo);
           pathsToMonitor.add(fo);
           break;
+        case FOLDER:
+          pathsToMonitor.add(fo);
+          for (FileObject child : fo.getChildren()) {
+            classpath.add(child);
+          }
+          break;
         case IMAGINARY:
           // assume its a pattern
           String pattern = fo.getName().getBaseName();
@@ -157,67 +162,67 @@ public class AccumuloVFSClassLoader {
           log.warn("ignoring classpath entry " + fo);
           break;
       }
-
+      
     }
-
+    
     return classpath.toArray(new FileObject[classpath.size()]);
   }
-
+  
   private static ReloadingClassLoader createDynamicClassloader(final ClassLoader parent)
throws FileSystemException, IOException {
     String dynamicCPath = AccumuloClassLoader.getAccumuloString(DYNAMIC_CLASSPATH_PROPERTY_NAME,
DEFAULT_DYNAMIC_CLASSPATH_VALUE);
-
+    
     String envJars = System.getenv("ACCUMULO_XTRAJARS");
     if (null != envJars && !envJars.equals(""))
       if (dynamicCPath != null && !dynamicCPath.equals(""))
         dynamicCPath = dynamicCPath + "," + envJars;
       else
         dynamicCPath = envJars;
-
+    
     ReloadingClassLoader wrapper = new ReloadingClassLoader() {
       @Override
       public ClassLoader getClassLoader() {
         return parent;
       }
     };
-
+    
     if (dynamicCPath == null || dynamicCPath.equals(""))
       return wrapper;
-
+    
     // TODO monitor time for lib/ext was 1 sec... should this be configurable? - ACCUMULO-1301
     return new AccumuloReloadingVFSClassLoader(dynamicCPath, generateVfs(), wrapper, 1000,
true);
   }
-
+  
   public static ClassLoader getClassLoader() throws IOException {
     ReloadingClassLoader localLoader = loader;
     while (null == localLoader) {
       synchronized (lock) {
         if (null == loader) {
-
+          
           FileSystemManager vfs = generateVfs();
-
+          
           // Set up the 2nd tier class loader
           if (null == parent) {
             parent = AccumuloClassLoader.getClassLoader();
           }
-
+          
           FileObject[] vfsCP = resolve(vfs, AccumuloClassLoader.getAccumuloString(VFS_CLASSLOADER_SYSTEM_CLASSPATH_PROPERTY,
""));
-
+          
           if (vfsCP.length == 0) {
             localLoader = createDynamicClassloader(parent);
             loader = localLoader;
             return localLoader.getClassLoader();
           }
-
+          
           // Create the Accumulo Context ClassLoader using the DEFAULT_CONTEXT
           localLoader = createDynamicClassloader(new VFSClassLoader(vfsCP, vfs, parent));
           loader = localLoader;
         }
       }
     }
-
+    
     return localLoader.getClassLoader();
   }
-
+  
   public static FileSystemManager generateVfs() throws FileSystemException {
     DefaultFileSystemManager vfs = new FinalCloseDefaultFileSystemManager();
     vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
@@ -263,11 +268,11 @@ public class AccumuloVFSClassLoader {
     vfsInstances.add(new WeakReference<DefaultFileSystemManager>(vfs));
     return vfs;
   }
-
+  
   public interface Printer {
     void print(String s);
   }
-
+  
   public static void printClassPath() {
     printClassPath(new Printer() {
       @Override
@@ -276,28 +281,28 @@ public class AccumuloVFSClassLoader {
       }
     });
   }
-
+  
   public static void printClassPath(Printer out) {
     try {
       ClassLoader cl = getClassLoader();
       ArrayList<ClassLoader> classloaders = new ArrayList<ClassLoader>();
-
+      
       while (cl != null) {
         classloaders.add(cl);
         cl = cl.getParent();
       }
-
+      
       Collections.reverse(classloaders);
-
+      
       int level = 0;
-
+      
       for (ClassLoader classLoader : classloaders) {
         if (level > 0)
           out.print("");
         level++;
-
+        
         String classLoaderDescription;
-
+        
         switch (level) {
           case 1:
             classLoaderDescription = level + ": Java System Classloader (loads Java system
resources)";
@@ -316,16 +321,16 @@ public class AccumuloVFSClassLoader {
                 + AccumuloVFSClassLoader.class.getName() + ")";
             break;
         }
-
+        
         if (classLoader instanceof URLClassLoader) {
           // If VFS class loader enabled, but no contexts defined.
           URLClassLoader ucl = (URLClassLoader) classLoader;
           out.print("Level " + classLoaderDescription + " URL classpath items are:");
-
+          
           for (URL u : ucl.getURLs()) {
             out.print("\t" + u.toExternalForm());
           }
-
+          
         } else if (classLoader instanceof VFSClassLoader) {
           out.print("Level " + classLoaderDescription + " VFS classpaths items are:");
           VFSClassLoader vcl = (VFSClassLoader) classLoader;
@@ -336,12 +341,12 @@ public class AccumuloVFSClassLoader {
           out.print("Unknown classloader configuration " + classLoader.getClass());
         }
       }
-
+      
     } catch (Throwable t) {
       throw new RuntimeException(t);
     }
   }
-
+  
   public static synchronized ContextManager getContextManager() throws IOException {
     if (contextManager == null) {
       getClassLoader();
@@ -356,10 +361,10 @@ public class AccumuloVFSClassLoader {
         }
       });
     }
-
+    
     return contextManager;
   }
-
+  
   public static void close() {
     for (WeakReference<DefaultFileSystemManager> vfsInstance : vfsInstances) {
       DefaultFileSystemManager ref = vfsInstance.get();


Mime
View raw message