accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlmar...@apache.org
Subject svn commit: r1445447 - in /accumulo/trunk: core/src/main/java/org/apache/accumulo/core/conf/ start/src/main/java/org/apache/accumulo/start/classloader/ start/src/main/java/org/apache/accumulo/start/classloader/vfs/
Date Wed, 13 Feb 2013 01:14:03 GMT
Author: dlmarion
Date: Wed Feb 13 01:14:03 2013
New Revision: 1445447

URL: http://svn.apache.org/r1445447
Log:
ACCUMULO-868 - added new property, which defaults to /tmp/accumulo-vfs-cache, for specifying
the vfs cache directory
ACCUMULO-1061 - re-added the shutdown hook


Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java
    accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
    accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java?rev=1445447&r1=1445446&r2=1445447&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/conf/Property.java Wed Feb
13 01:14:03 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.core.conf;
 
+import java.io.File;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Set;
@@ -335,7 +336,14 @@ public enum Property {
           + "The value is a comma seperated list of URIs. Supports full regex on filename
alone. For example general.vfs.context.classpath.cx1=hdfs://nn1:9902/mylibdir/*.jar.  "
           + "You can enable post delegation for a context, which will load classes from the
context first instead of the parent first.  "
           + "Do this by setting general.vfs.context.classpath.<name>.delegation=post,
where <name> is your context name.  "
-          + "If delegation is not specified, it defaults to loading from parent classloader
first.");
+          + "If delegation is not specified, it defaults to loading from parent classloader
first."),
+ VFS_CLASSLOADER_CACHE_DIR(
+	    AccumuloVFSClassLoader.VFS_CACHE_DIR,
+	    new File(System.getProperty("java.io.tmpdir"), "accumulo-vfs-cache")
+		    .getAbsolutePath(),
+	    PropertyType.ABSOLUTEPATH,
+	    "Directory to use for the vfs cache. The cache will keep a soft reference to all of
the classes loaded in the VM. This should be on local disk on each node with sufficient space.
It defaults to /tmp",
+	    false);
   
   private String key, defaultValue, description;
   private PropertyType type;

Modified: accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java?rev=1445447&r1=1445446&r2=1445447&view=diff
==============================================================================
--- accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
(original)
+++ accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/AccumuloClassLoader.java
Wed Feb 13 01:14:03 2013
@@ -62,10 +62,6 @@ public class AccumuloClassLoader {
     } else {
       SITE_CONF = null;
     }
-    
-    // Register the shutdown hook
-    // TODO
-    // Runtime.getRuntime().addShutdownHook(new Thread(new AccumuloVFSClassLoaderShutdownThread()));
   }
   
   /**

Modified: accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java?rev=1445447&r1=1445446&r2=1445447&view=diff
==============================================================================
--- accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
(original)
+++ accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
Wed Feb 13 01:14:03 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.start.classloader.vfs;
 
+import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -29,7 +30,6 @@ import org.apache.commons.vfs2.FileObjec
 import org.apache.commons.vfs2.FileSystemException;
 import org.apache.commons.vfs2.FileSystemManager;
 import org.apache.commons.vfs2.FileType;
-import org.apache.commons.vfs2.cache.DefaultFilesCache;
 import org.apache.commons.vfs2.cache.SoftRefFilesCache;
 import org.apache.commons.vfs2.impl.DefaultFileReplicator;
 import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
@@ -61,7 +61,11 @@ public class AccumuloVFSClassLoader {
   public static class AccumuloVFSClassLoaderShutdownThread implements Runnable {
 
     public void run() {
-      AccumuloVFSClassLoader.close();
+      try {
+	AccumuloVFSClassLoader.close();
+      } catch (Exception e) {
+	  //do nothing, we are shutting down anyway
+      }
     }
     
   }
@@ -74,6 +78,8 @@ public class AccumuloVFSClassLoader {
   
   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 DefaultFileSystemManager vfs = null;
   private static ClassLoader parent = null;
   private static volatile ReloadingClassLoader loader = null;
@@ -83,6 +89,11 @@ public class AccumuloVFSClassLoader {
 
   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);
@@ -186,8 +197,6 @@ public class AccumuloVFSClassLoader {
           
           if (null == vfs) {
             vfs = new DefaultFileSystemManager();
-            //TODO: Might be able to use a different cache impl or specify cache directory
in configuration.
-            vfs.setFilesCache(new DefaultFilesCache());
             vfs.addProvider("res", new org.apache.commons.vfs2.provider.res.ResourceFileProvider());
             vfs.addProvider("zip", new org.apache.commons.vfs2.provider.zip.ZipFileProvider());
             vfs.addProvider("gz", new org.apache.commons.vfs2.provider.gzip.GzipFileProvider());
@@ -221,7 +230,11 @@ public class AccumuloVFSClassLoader {
             vfs.addMimeTypeMap("application/zip", "zip");
             vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
             vfs.setFilesCache(new SoftRefFilesCache());
-            vfs.setReplicator(new DefaultFileReplicator());
+            String cacheDirPath = AccumuloClassLoader.getAccumuloString(VFS_CACHE_DIR, "");
+            File cacheDir = new File(System.getProperty("java.io.tmpdir"), "accumulo-vfs-cache");
+            if (!("".equals(cacheDirPath)))
+        	cacheDir = new File(cacheDirPath);
+            vfs.setReplicator(new DefaultFileReplicator(cacheDir));
             vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
             vfs.init();
           }



Mime
View raw message