accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [1/2] git commit: ACCUMULO-3024 put all VFS caches in their own directory, delete the process-specific directory in the shutdown hook
Date Tue, 05 Aug 2014 17:36:21 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master cfe8ee548 -> c3d219560


ACCUMULO-3024 put all VFS caches in their own directory, delete the process-specific directory
in the shutdown hook


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

Branch: refs/heads/master
Commit: 5a90ed76805bf03427b8d382457a7746c6069fee
Parents: d647204
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Tue Aug 5 13:32:43 2014 -0400
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Tue Aug 5 13:32:43 2014 -0400

----------------------------------------------------------------------
 .../classloader/vfs/AccumuloVFSClassLoader.java | 16 +++++++++----
 .../vfs/FinalCloseDefaultFileSystemManager.java | 25 --------------------
 2 files changed, 12 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/5a90ed76/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 9f0f650..49c5b99 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
@@ -25,6 +25,7 @@ import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.start.classloader.AccumuloClassLoader;
 import org.apache.accumulo.start.classloader.vfs.providers.HdfsFileObject;
@@ -89,6 +90,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";
+  
+  public static final AtomicInteger uniqueDirectoryGenerator = new AtomicInteger(0);
 
   private static ClassLoader parent = null;
   private static volatile ReloadingClassLoader loader = null;
@@ -241,7 +244,7 @@ public class AccumuloVFSClassLoader {
   }
 
   public static FileSystemManager generateVfs() throws FileSystemException {
-    DefaultFileSystemManager vfs = new FinalCloseDefaultFileSystemManager();
+    DefaultFileSystemManager vfs = new DefaultFileSystemManager();
     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());
@@ -276,10 +279,9 @@ public class AccumuloVFSClassLoader {
     vfs.setFileContentInfoFactory(new FileContentInfoFilenameFactory());
     vfs.setFilesCache(new SoftRefFilesCache());
     String cacheDirPath = AccumuloClassLoader.getAccumuloString(VFS_CACHE_DIR, "");
-    String procName = ManagementFactory.getRuntimeMXBean().getName();
-    File cacheDir = new File(System.getProperty("java.io.tmpdir"), "accumulo-vfs-cache-"
+ procName + "-" + System.getProperty("user.name", "nouser"));
+    File cacheDir = computeTopCacheDir(); 
     if (!cacheDirPath.isEmpty())
-      cacheDir = new File(cacheDirPath);
+      cacheDir = new File(cacheDirPath, "" + uniqueDirectoryGenerator.getAndIncrement());
     vfs.setReplicator(new UniqueFileReplicator(cacheDir));
     vfs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
     vfs.init();
@@ -287,6 +289,11 @@ public class AccumuloVFSClassLoader {
     return vfs;
   }
 
+  private static File computeTopCacheDir() {
+    String procName = ManagementFactory.getRuntimeMXBean().getName();
+    return new File(System.getProperty("java.io.tmpdir"), "accumulo-vfs-cache-" + procName
+ "-" + System.getProperty("user.name", "nouser"));
+  }
+
   public interface Printer {
     void print(String s);
   }
@@ -399,5 +406,6 @@ public class AccumuloVFSClassLoader {
         ref.close();
       }
     }
+    computeTopCacheDir().delete();
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/5a90ed76/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
----------------------------------------------------------------------
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
deleted file mode 100644
index a6cc19a..0000000
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/FinalCloseDefaultFileSystemManager.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.start.classloader.vfs;
-
-import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
-
-public class FinalCloseDefaultFileSystemManager extends DefaultFileSystemManager {
-  protected void finalize() {
-    close();
-  }
-}


Mime
View raw message