You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2014/03/26 01:35:15 UTC

[01/11] git commit: ACCUMULO-2532 Use VolumeManager to check for tmpDir existence.

Repository: accumulo
Updated Branches:
  refs/heads/1.6.0-SNAPSHOT ce38eeadc -> f3f54806d
  refs/heads/master eb72c5ba0 -> 36745b5a4


ACCUMULO-2532 Use VolumeManager to check for tmpDir existence.


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 74ffff1a189c807995c33d400aca4fed7b183d38
Parents: 6420dd3
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 15:56:03 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:08:33 2014 -0700

----------------------------------------------------------------------
 .../apache/accumulo/server/util/FileUtil.java   |  21 ++--
 .../accumulo/server/util/FileUtilTest.java      | 117 +++++++++++++++----
 2 files changed, 105 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/74ffff1a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
index fa186aa..4fee83d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
@@ -45,6 +45,7 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.system.MultiIterator;
 import org.apache.accumulo.core.util.CachedConfiguration;
 import org.apache.accumulo.core.util.LocalityGroupUtil;
+import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.fs.FileRef;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -359,7 +360,7 @@ public class FileUtil {
       cleanupIndexOp(acuConf, tmpDir, fs, readers);
     }
   }
-  
+
   protected static void cleanupIndexOp(AccumuloConfiguration acuConf, Path tmpDir, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
     // close all of the index sequence files
     for (FileSKVIterator r : readers) {
@@ -371,20 +372,18 @@ public class FileUtil {
         log.error(e, e);
       }
     }
-    
+
     if (tmpDir != null) {
-      // TODO ACCUMULO-2532 instance.dfs.dir is not required to be a part of 
-      // the path for tmpDir. Could result in tmpDir not being removed when it should
-      // Needs unit tests
-      @SuppressWarnings("deprecation")
-      String tmpPrefix = acuConf.get(Property.INSTANCE_DFS_DIR) + "/tmp";
-      if (tmpDir.toUri().getPath().startsWith(tmpPrefix))
+      Volume v = fs.getVolumeByPath(tmpDir);
+      if (v.getFileSystem().exists(tmpDir)) {
         fs.deleteRecursively(tmpDir);
-      else
-        log.error("Did not delete tmp dir because it wasn't a tmp dir " + tmpDir);
+        return;
+      }
+
+      log.error("Did not delete tmp dir because it wasn't a tmp dir " + tmpDir);
     }
   }
-  
+
   private static long countIndexEntries(AccumuloConfiguration acuConf, Text prevEndRow, Text endRow, Collection<String> mapFiles, boolean useIndex,
       Configuration conf, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/74ffff1a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
index 546b4ee..86678e1 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
@@ -44,21 +44,21 @@ public class FileUtilTest {
   @Test
   public void testCleanupIndexOpWithDfsDir() throws IOException {
     File dfsDir = Files.createTempDir();
-    
+
     try {
       // And a "unique" tmp directory for each volume
       File tmp1 = new File(dfsDir, "tmp");
       tmp1.mkdirs();
       Path tmpPath1 = new Path(tmp1.toURI());
-      
+
       HashMap<Property,String> testProps = new HashMap<Property,String>();
       testProps.put(Property.INSTANCE_DFS_DIR, dfsDir.getAbsolutePath());
-      
+
       AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
       VolumeManager fs = VolumeManagerImpl.getLocal(dfsDir.getAbsolutePath());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
     } finally {
       FileUtils.deleteQuietly(dfsDir);
@@ -68,7 +68,7 @@ public class FileUtilTest {
   @Test
   public void testCleanupIndexOpWithCommonParentVolume() throws IOException {
     File accumuloDir = Files.createTempDir();
-    
+
     try {
       File volumeDir = new File(accumuloDir, "volumes");
       volumeDir.mkdirs();
@@ -83,19 +83,57 @@ public class FileUtilTest {
       tmp1.mkdirs();
       tmp2.mkdirs();
       Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
-      
+
       HashMap<Property,String> testProps = new HashMap<Property,String>();
       testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
-      
+
       AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
       VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
-      
+
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithCommonParentVolumeWithDepth() throws IOException {
+    File accumuloDir = Files.createTempDir();
+
+    try {
+      File volumeDir = new File(accumuloDir, "volumes");
+      volumeDir.mkdirs();
+
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(volumeDir, "v1"), v2 = new File(volumeDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      // Make sure we can handle nested directories (a single tmpdir with potentially multiple unique dirs)
+      File tmp1 = new File(new File(v1, "tmp"), "tmp_1"), tmp2 = new File(new File(v2, "tmp"), "tmp_1");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+
       Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
     } finally {
       FileUtils.deleteQuietly(accumuloDir);
@@ -105,7 +143,7 @@ public class FileUtilTest {
   @Test
   public void testCleanupIndexOpWithoutCommonParentVolume() throws IOException {
     File accumuloDir = Files.createTempDir();
-    
+
     try {
       // Make some directories to simulate multiple volumes
       File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
@@ -117,19 +155,54 @@ public class FileUtilTest {
       tmp1.mkdirs();
       tmp2.mkdirs();
       Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
-      
+
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithoutCommonParentVolumeWithDepth() throws IOException {
+    File accumuloDir = Files.createTempDir();
+
+    try {
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      // Make sure we can handle nested directories (a single tmpdir with potentially multiple unique dirs)
+      File tmp1 = new File(new File(v1, "tmp"), "tmp_1"), tmp2 = new File(new File(v2, "tmp"), "tmp_1");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+
       HashMap<Property,String> testProps = new HashMap<Property,String>();
       testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
-      
+
       AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
       VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
     } finally {
       FileUtils.deleteQuietly(accumuloDir);
@@ -139,11 +212,11 @@ public class FileUtilTest {
   private static class FileUtilTestConfiguration extends AccumuloConfiguration {
     private DefaultConfiguration defaultConf = new DefaultConfiguration();
     private Map<Property,String> properties;
-    
+
     public FileUtilTestConfiguration(Map<Property,String> properties) {
       this.properties = properties;
     }
-    
+
     @Override
     public String get(Property property) {
       String value = properties.get(property);
@@ -157,6 +230,6 @@ public class FileUtilTest {
     public void getProperties(Map<String,String> props, PropertyFilter filter) {
       throw new UnsupportedOperationException();
     }
-    
+
   }
 }


[06/11] git commit: ACCUMULO-2532 Expand on comment as to why we create this (otherwise curious) file

Posted by el...@apache.org.
ACCUMULO-2532 Expand on comment as to why we create this (otherwise curious) file


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

Branch: refs/heads/master
Commit: 9678a2c51a33cc8c58969450e81c0acf40714930
Parents: 74ffff1
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 16:09:50 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:09:50 2014 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/accumulo/server/util/FileUtil.java    | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/9678a2c5/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
index 4fee83d..0f7ac22 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
@@ -96,6 +96,8 @@ public class FileUtil {
       fs.mkdirs(result);
       
       // try to reserve the tmp dir
+      // In some versions of hadoop, two clients concurrently trying to create the same directory might both return true
+      // Creating a file is not subject to this, so create a special file to make sure we solely will use this directory
       if (!fs.createNewFile(new Path(result, "__reserve")))
         result = null;
     }


[04/11] git commit: ACCUMULO-2532 Relax access on cleanupIndexOp and add tests that show failure case.

Posted by el...@apache.org.
ACCUMULO-2532 Relax access on cleanupIndexOp and add tests that show failure case.


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

Branch: refs/heads/master
Commit: 6420dd3d49c97ee5c9a5e173914ca5374a26c8e5
Parents: ce38eea
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 15:27:43 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:08:33 2014 -0700

----------------------------------------------------------------------
 .../apache/accumulo/server/util/FileUtil.java   |   2 +-
 .../accumulo/server/util/FileUtilTest.java      | 162 +++++++++++++++++++
 2 files changed, 163 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/6420dd3d/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
index b1e39f0..fa186aa 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
@@ -360,7 +360,7 @@ public class FileUtil {
     }
   }
   
-  private static void cleanupIndexOp(AccumuloConfiguration acuConf, Path tmpDir, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
+  protected static void cleanupIndexOp(AccumuloConfiguration acuConf, Path tmpDir, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
     // close all of the index sequence files
     for (FileSKVIterator r : readers) {
       try {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/6420dd3d/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
new file mode 100644
index 0000000..546b4ee
--- /dev/null
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
@@ -0,0 +1,162 @@
+/*
+ * 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.server.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.DefaultConfiguration;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.file.FileSKVIterator;
+import org.apache.accumulo.server.fs.VolumeManager;
+import org.apache.accumulo.server.fs.VolumeManagerImpl;
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.fs.Path;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.io.Files;
+
+/**
+ * 
+ */
+public class FileUtilTest {
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void testCleanupIndexOpWithDfsDir() throws IOException {
+    File dfsDir = Files.createTempDir();
+    
+    try {
+      // And a "unique" tmp directory for each volume
+      File tmp1 = new File(dfsDir, "tmp");
+      tmp1.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI());
+      
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_DFS_DIR, dfsDir.getAbsolutePath());
+      
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(dfsDir.getAbsolutePath());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+    } finally {
+      FileUtils.deleteQuietly(dfsDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithCommonParentVolume() throws IOException {
+    File accumuloDir = Files.createTempDir();
+    
+    try {
+      File volumeDir = new File(accumuloDir, "volumes");
+      volumeDir.mkdirs();
+
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(volumeDir, "v1"), v2 = new File(volumeDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      File tmp1 = new File(v1, "tmp"), tmp2 = new File(v2, "tmp");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+      
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+      
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithoutCommonParentVolume() throws IOException {
+    File accumuloDir = Files.createTempDir();
+    
+    try {
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      File tmp1 = new File(v1, "tmp"), tmp2 = new File(v2, "tmp");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+      
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+      
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  private static class FileUtilTestConfiguration extends AccumuloConfiguration {
+    private DefaultConfiguration defaultConf = new DefaultConfiguration();
+    private Map<Property,String> properties;
+    
+    public FileUtilTestConfiguration(Map<Property,String> properties) {
+      this.properties = properties;
+    }
+    
+    @Override
+    public String get(Property property) {
+      String value = properties.get(property);
+      if (null != value) {
+        return value;
+      }
+      return defaultConf.get(property);
+    }
+
+    @Override
+    public void getProperties(Map<String,String> props, PropertyFilter filter) {
+      throw new UnsupportedOperationException();
+    }
+    
+  }
+}


[03/11] git commit: ACCUMULO-2532 Use VolumeManager to check for tmpDir existence.

Posted by el...@apache.org.
ACCUMULO-2532 Use VolumeManager to check for tmpDir existence.


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

Branch: refs/heads/master
Commit: 74ffff1a189c807995c33d400aca4fed7b183d38
Parents: 6420dd3
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 15:56:03 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:08:33 2014 -0700

----------------------------------------------------------------------
 .../apache/accumulo/server/util/FileUtil.java   |  21 ++--
 .../accumulo/server/util/FileUtilTest.java      | 117 +++++++++++++++----
 2 files changed, 105 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/74ffff1a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
index fa186aa..4fee83d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
@@ -45,6 +45,7 @@ import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.system.MultiIterator;
 import org.apache.accumulo.core.util.CachedConfiguration;
 import org.apache.accumulo.core.util.LocalityGroupUtil;
+import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.fs.FileRef;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -359,7 +360,7 @@ public class FileUtil {
       cleanupIndexOp(acuConf, tmpDir, fs, readers);
     }
   }
-  
+
   protected static void cleanupIndexOp(AccumuloConfiguration acuConf, Path tmpDir, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
     // close all of the index sequence files
     for (FileSKVIterator r : readers) {
@@ -371,20 +372,18 @@ public class FileUtil {
         log.error(e, e);
       }
     }
-    
+
     if (tmpDir != null) {
-      // TODO ACCUMULO-2532 instance.dfs.dir is not required to be a part of 
-      // the path for tmpDir. Could result in tmpDir not being removed when it should
-      // Needs unit tests
-      @SuppressWarnings("deprecation")
-      String tmpPrefix = acuConf.get(Property.INSTANCE_DFS_DIR) + "/tmp";
-      if (tmpDir.toUri().getPath().startsWith(tmpPrefix))
+      Volume v = fs.getVolumeByPath(tmpDir);
+      if (v.getFileSystem().exists(tmpDir)) {
         fs.deleteRecursively(tmpDir);
-      else
-        log.error("Did not delete tmp dir because it wasn't a tmp dir " + tmpDir);
+        return;
+      }
+
+      log.error("Did not delete tmp dir because it wasn't a tmp dir " + tmpDir);
     }
   }
-  
+
   private static long countIndexEntries(AccumuloConfiguration acuConf, Text prevEndRow, Text endRow, Collection<String> mapFiles, boolean useIndex,
       Configuration conf, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/74ffff1a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
index 546b4ee..86678e1 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
@@ -44,21 +44,21 @@ public class FileUtilTest {
   @Test
   public void testCleanupIndexOpWithDfsDir() throws IOException {
     File dfsDir = Files.createTempDir();
-    
+
     try {
       // And a "unique" tmp directory for each volume
       File tmp1 = new File(dfsDir, "tmp");
       tmp1.mkdirs();
       Path tmpPath1 = new Path(tmp1.toURI());
-      
+
       HashMap<Property,String> testProps = new HashMap<Property,String>();
       testProps.put(Property.INSTANCE_DFS_DIR, dfsDir.getAbsolutePath());
-      
+
       AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
       VolumeManager fs = VolumeManagerImpl.getLocal(dfsDir.getAbsolutePath());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
     } finally {
       FileUtils.deleteQuietly(dfsDir);
@@ -68,7 +68,7 @@ public class FileUtilTest {
   @Test
   public void testCleanupIndexOpWithCommonParentVolume() throws IOException {
     File accumuloDir = Files.createTempDir();
-    
+
     try {
       File volumeDir = new File(accumuloDir, "volumes");
       volumeDir.mkdirs();
@@ -83,19 +83,57 @@ public class FileUtilTest {
       tmp1.mkdirs();
       tmp2.mkdirs();
       Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
-      
+
       HashMap<Property,String> testProps = new HashMap<Property,String>();
       testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
-      
+
       AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
       VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
-      
+
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithCommonParentVolumeWithDepth() throws IOException {
+    File accumuloDir = Files.createTempDir();
+
+    try {
+      File volumeDir = new File(accumuloDir, "volumes");
+      volumeDir.mkdirs();
+
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(volumeDir, "v1"), v2 = new File(volumeDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      // Make sure we can handle nested directories (a single tmpdir with potentially multiple unique dirs)
+      File tmp1 = new File(new File(v1, "tmp"), "tmp_1"), tmp2 = new File(new File(v2, "tmp"), "tmp_1");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+
       Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
     } finally {
       FileUtils.deleteQuietly(accumuloDir);
@@ -105,7 +143,7 @@ public class FileUtilTest {
   @Test
   public void testCleanupIndexOpWithoutCommonParentVolume() throws IOException {
     File accumuloDir = Files.createTempDir();
-    
+
     try {
       // Make some directories to simulate multiple volumes
       File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
@@ -117,19 +155,54 @@ public class FileUtilTest {
       tmp1.mkdirs();
       tmp2.mkdirs();
       Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
-      
+
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithoutCommonParentVolumeWithDepth() throws IOException {
+    File accumuloDir = Files.createTempDir();
+
+    try {
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      // Make sure we can handle nested directories (a single tmpdir with potentially multiple unique dirs)
+      File tmp1 = new File(new File(v1, "tmp"), "tmp_1"), tmp2 = new File(new File(v2, "tmp"), "tmp_1");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+
       HashMap<Property,String> testProps = new HashMap<Property,String>();
       testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
-      
+
       AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
       VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
-      
+
       FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
-      
+
       Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
     } finally {
       FileUtils.deleteQuietly(accumuloDir);
@@ -139,11 +212,11 @@ public class FileUtilTest {
   private static class FileUtilTestConfiguration extends AccumuloConfiguration {
     private DefaultConfiguration defaultConf = new DefaultConfiguration();
     private Map<Property,String> properties;
-    
+
     public FileUtilTestConfiguration(Map<Property,String> properties) {
       this.properties = properties;
     }
-    
+
     @Override
     public String get(Property property) {
       String value = properties.get(property);
@@ -157,6 +230,6 @@ public class FileUtilTest {
     public void getProperties(Map<String,String> props, PropertyFilter filter) {
       throw new UnsupportedOperationException();
     }
-    
+
   }
 }


[09/11] git commit: ACCUMULO-2530 add TODO in code to reference ticket

Posted by el...@apache.org.
ACCUMULO-2530 add TODO in code to reference ticket


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: f3f54806d8af1bb12da549260338977ffd370e5d
Parents: f857e20
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 16:30:11 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:30:11 2014 -0700

----------------------------------------------------------------------
 .../security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java   | 3 ++-
 .../security/crypto/NonCachingSecretKeyEncryptionStrategy.java    | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f3f54806/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
index d25d08c..e5ad13d 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
@@ -128,7 +128,8 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
       if (pathToKeyName == null || pathToKeyName.equals("")) {
         pathToKeyName = Property.CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION.getDefaultValue();
       }
-      
+
+      // TODO ACCUMULO-2530 Ensure volumes a properly supported
       Path pathToKey = new Path(pathToKeyName);  
       FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());   
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/f3f54806/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
index efcec01..67278bf 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
@@ -153,6 +153,7 @@ public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptio
     Path pathToKey = new Path(fullPath);
     
     try {
+      // TODO ACCUMULO-2530 Ensure volumes a properly supported
       FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());   
       doKeyEncryptionOperation(Cipher.WRAP_MODE, params, fullPath, pathToKey, fs);
       
@@ -176,6 +177,7 @@ public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptio
     Path pathToKey = new Path(pathToKeyName);
     
     try {
+      // TODO ACCUMULO-2530 Ensure volumes a properly supported
       FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());   
       doKeyEncryptionOperation(Cipher.UNWRAP_MODE, params, pathToKeyName, pathToKey, fs);
       


[02/11] git commit: ACCUMULO-2532 Relax access on cleanupIndexOp and add tests that show failure case.

Posted by el...@apache.org.
ACCUMULO-2532 Relax access on cleanupIndexOp and add tests that show failure case.


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 6420dd3d49c97ee5c9a5e173914ca5374a26c8e5
Parents: ce38eea
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 15:27:43 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:08:33 2014 -0700

----------------------------------------------------------------------
 .../apache/accumulo/server/util/FileUtil.java   |   2 +-
 .../accumulo/server/util/FileUtilTest.java      | 162 +++++++++++++++++++
 2 files changed, 163 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/6420dd3d/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
index b1e39f0..fa186aa 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
@@ -360,7 +360,7 @@ public class FileUtil {
     }
   }
   
-  private static void cleanupIndexOp(AccumuloConfiguration acuConf, Path tmpDir, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
+  protected static void cleanupIndexOp(AccumuloConfiguration acuConf, Path tmpDir, VolumeManager fs, ArrayList<FileSKVIterator> readers) throws IOException {
     // close all of the index sequence files
     for (FileSKVIterator r : readers) {
       try {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/6420dd3d/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
new file mode 100644
index 0000000..546b4ee
--- /dev/null
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
@@ -0,0 +1,162 @@
+/*
+ * 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.server.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.DefaultConfiguration;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.file.FileSKVIterator;
+import org.apache.accumulo.server.fs.VolumeManager;
+import org.apache.accumulo.server.fs.VolumeManagerImpl;
+import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.fs.Path;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.common.io.Files;
+
+/**
+ * 
+ */
+public class FileUtilTest {
+
+  @SuppressWarnings("deprecation")
+  @Test
+  public void testCleanupIndexOpWithDfsDir() throws IOException {
+    File dfsDir = Files.createTempDir();
+    
+    try {
+      // And a "unique" tmp directory for each volume
+      File tmp1 = new File(dfsDir, "tmp");
+      tmp1.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI());
+      
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_DFS_DIR, dfsDir.getAbsolutePath());
+      
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(dfsDir.getAbsolutePath());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+    } finally {
+      FileUtils.deleteQuietly(dfsDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithCommonParentVolume() throws IOException {
+    File accumuloDir = Files.createTempDir();
+    
+    try {
+      File volumeDir = new File(accumuloDir, "volumes");
+      volumeDir.mkdirs();
+
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(volumeDir, "v1"), v2 = new File(volumeDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      File tmp1 = new File(v1, "tmp"), tmp2 = new File(v2, "tmp");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+      
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+      
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  @Test
+  public void testCleanupIndexOpWithoutCommonParentVolume() throws IOException {
+    File accumuloDir = Files.createTempDir();
+    
+    try {
+      // Make some directories to simulate multiple volumes
+      File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
+      v1.mkdirs();
+      v2.mkdirs();
+
+      // And a "unique" tmp directory for each volume
+      File tmp1 = new File(v1, "tmp"), tmp2 = new File(v2, "tmp");
+      tmp1.mkdirs();
+      tmp2.mkdirs();
+      Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
+      
+      HashMap<Property,String> testProps = new HashMap<Property,String>();
+      testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
+      
+      AccumuloConfiguration testConf = new FileUtilTestConfiguration(testProps);
+      VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath1, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
+      
+      FileUtil.cleanupIndexOp(testConf, tmpPath2, fs, new ArrayList<FileSKVIterator>());
+      
+      Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
+    } finally {
+      FileUtils.deleteQuietly(accumuloDir);
+    }
+  }
+
+  private static class FileUtilTestConfiguration extends AccumuloConfiguration {
+    private DefaultConfiguration defaultConf = new DefaultConfiguration();
+    private Map<Property,String> properties;
+    
+    public FileUtilTestConfiguration(Map<Property,String> properties) {
+      this.properties = properties;
+    }
+    
+    @Override
+    public String get(Property property) {
+      String value = properties.get(property);
+      if (null != value) {
+        return value;
+      }
+      return defaultConf.get(property);
+    }
+
+    @Override
+    public void getProperties(Map<String,String> props, PropertyFilter filter) {
+      throw new UnsupportedOperationException();
+    }
+    
+  }
+}


[07/11] git commit: ACCUMULO-2462 Add TODO marker for bcfile.PrintInfo

Posted by el...@apache.org.
ACCUMULO-2462 Add TODO marker for bcfile.PrintInfo


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: f857e20e8d92eb8c9a7238704a25ac323a3a0336
Parents: 9678a2c
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 16:24:29 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:24:29 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f857e20e/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
index e2c8a6d..f387cc2 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
@@ -57,6 +57,7 @@ public class PrintInfo {
     Configuration conf = new Configuration();
     @SuppressWarnings("deprecation")
     AccumuloConfiguration siteConf = AccumuloConfiguration.getSiteConfiguration();
+    // TODO ACCUMULO-2462 not going to operate as expected with volumes when a path, not URI, is given
     FileSystem hadoopFs = VolumeConfiguration.getDefaultVolume(conf, siteConf).getFileSystem();
     FileSystem localFs = FileSystem.getLocal(conf);
     Path path = new Path(args[0]);


[08/11] git commit: ACCUMULO-2462 Add TODO marker for bcfile.PrintInfo

Posted by el...@apache.org.
ACCUMULO-2462 Add TODO marker for bcfile.PrintInfo


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

Branch: refs/heads/master
Commit: f857e20e8d92eb8c9a7238704a25ac323a3a0336
Parents: 9678a2c
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 16:24:29 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:24:29 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f857e20e/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
index e2c8a6d..f387cc2 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/PrintInfo.java
@@ -57,6 +57,7 @@ public class PrintInfo {
     Configuration conf = new Configuration();
     @SuppressWarnings("deprecation")
     AccumuloConfiguration siteConf = AccumuloConfiguration.getSiteConfiguration();
+    // TODO ACCUMULO-2462 not going to operate as expected with volumes when a path, not URI, is given
     FileSystem hadoopFs = VolumeConfiguration.getDefaultVolume(conf, siteConf).getFileSystem();
     FileSystem localFs = FileSystem.getLocal(conf);
     Path path = new Path(args[0]);


[10/11] git commit: ACCUMULO-2530 add TODO in code to reference ticket

Posted by el...@apache.org.
ACCUMULO-2530 add TODO in code to reference ticket


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

Branch: refs/heads/master
Commit: f3f54806d8af1bb12da549260338977ffd370e5d
Parents: f857e20
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 16:30:11 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:30:11 2014 -0700

----------------------------------------------------------------------
 .../security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java   | 3 ++-
 .../security/crypto/NonCachingSecretKeyEncryptionStrategy.java    | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/f3f54806/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
index d25d08c..e5ad13d 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/CachingHDFSSecretKeyEncryptionStrategy.java
@@ -128,7 +128,8 @@ public class CachingHDFSSecretKeyEncryptionStrategy implements SecretKeyEncrypti
       if (pathToKeyName == null || pathToKeyName.equals("")) {
         pathToKeyName = Property.CRYPTO_DEFAULT_KEY_STRATEGY_KEY_LOCATION.getDefaultValue();
       }
-      
+
+      // TODO ACCUMULO-2530 Ensure volumes a properly supported
       Path pathToKey = new Path(pathToKeyName);  
       FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());   
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/f3f54806/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java b/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
index efcec01..67278bf 100644
--- a/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
+++ b/core/src/main/java/org/apache/accumulo/core/security/crypto/NonCachingSecretKeyEncryptionStrategy.java
@@ -153,6 +153,7 @@ public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptio
     Path pathToKey = new Path(fullPath);
     
     try {
+      // TODO ACCUMULO-2530 Ensure volumes a properly supported
       FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());   
       doKeyEncryptionOperation(Cipher.WRAP_MODE, params, fullPath, pathToKey, fs);
       
@@ -176,6 +177,7 @@ public class NonCachingSecretKeyEncryptionStrategy implements SecretKeyEncryptio
     Path pathToKey = new Path(pathToKeyName);
     
     try {
+      // TODO ACCUMULO-2530 Ensure volumes a properly supported
       FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());   
       doKeyEncryptionOperation(Cipher.UNWRAP_MODE, params, pathToKeyName, pathToKey, fs);
       


[05/11] git commit: ACCUMULO-2532 Expand on comment as to why we create this (otherwise curious) file

Posted by el...@apache.org.
ACCUMULO-2532 Expand on comment as to why we create this (otherwise curious) file


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

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 9678a2c51a33cc8c58969450e81c0acf40714930
Parents: 74ffff1
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 16:09:50 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 16:09:50 2014 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/accumulo/server/util/FileUtil.java    | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/9678a2c5/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
index 4fee83d..0f7ac22 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/FileUtil.java
@@ -96,6 +96,8 @@ public class FileUtil {
       fs.mkdirs(result);
       
       // try to reserve the tmp dir
+      // In some versions of hadoop, two clients concurrently trying to create the same directory might both return true
+      // Creating a file is not subject to this, so create a special file to make sure we solely will use this directory
       if (!fs.createNewFile(new Path(result, "__reserve")))
         result = null;
     }


[11/11] git commit: Merge branch '1.6.0-SNAPSHOT'

Posted by el...@apache.org.
Merge branch '1.6.0-SNAPSHOT'


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

Branch: refs/heads/master
Commit: 36745b5a4a351e503ad27a7d1654fb76c2bd86e3
Parents: eb72c5b f3f5480
Author: Josh Elser <el...@apache.org>
Authored: Tue Mar 25 17:34:52 2014 -0700
Committer: Josh Elser <el...@apache.org>
Committed: Tue Mar 25 17:34:52 2014 -0700

----------------------------------------------------------------------
 .../core/file/rfile/bcfile/PrintInfo.java       |   1 +
 .../CachingHDFSSecretKeyEncryptionStrategy.java |   3 +-
 .../NonCachingSecretKeyEncryptionStrategy.java  |   2 +
 .../apache/accumulo/server/util/FileUtil.java   |  25 +-
 .../accumulo/server/util/FileUtilTest.java      | 235 +++++++++++++++++++
 5 files changed, 253 insertions(+), 13 deletions(-)
----------------------------------------------------------------------