Repository: accumulo
Updated Branches:
  refs/heads/master 16979a0b8 -> 81ab2d9c7


ACCUMULO-1832 added some javadoc to VolumeUtil


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

Branch: refs/heads/master
Commit: b45313bebc9a221d517f523ce092aaa6e1348315
Parents: b23408f
Author: Keith Turner <ktur...@apache.org>
Authored: Tue Feb 25 18:21:39 2014 -0500
Committer: Keith Turner <ktur...@apache.org>
Committed: Tue Feb 25 18:21:39 2014 -0500

----------------------------------------------------------------------
 .../apache/accumulo/server/ServerConstants.java |  4 +--
 .../apache/accumulo/server/fs/VolumeUtil.java   | 26 +++++++++++++-------
 2 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/b45313be/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
----------------------------------------------------------------------
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java 
b/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
index ca5783b..cca869a 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerConstants.java
@@ -237,7 +237,7 @@ public class ServerConstants {
         Path p1, p2;
         try {
           // URI constructor handles hex escaping
-          p1 = new Path(new URI(VolumeUtil.removeSlash(uris[0].trim())));
+          p1 = new Path(new 
URI(VolumeUtil.removeTrailingSlash(uris[0].trim())));
           if (p1.toUri().getScheme() == null)
             throw new 
IllegalArgumentException(Property.INSTANCE_VOLUMES_REPLACEMENTS.getKey() + " 
contains " + uris[0] + " which is not fully qualified");
         } catch (URISyntaxException e) {
@@ -245,7 +245,7 @@ public class ServerConstants {
         }
 
         try {
-          p2 = new Path(new URI(VolumeUtil.removeSlash(uris[1].trim())));
+          p2 = new Path(new 
URI(VolumeUtil.removeTrailingSlash(uris[1].trim())));
           if (p2.toUri().getScheme() == null)
             throw new 
IllegalArgumentException(Property.INSTANCE_VOLUMES_REPLACEMENTS.getKey() + " 
contains " + uris[1] + " which is not fully qualified");
         } catch (URISyntaxException e) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/b45313be/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
----------------------------------------------------------------------
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java 
b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
index 4f8d5e8..da3baa6 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeUtil.java
@@ -45,11 +45,15 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 
+/**
+ * Utility methods for managing absolute URIs contained in Accumulo metadata.
+ */
+
 public class VolumeUtil {
 
   private static final Logger log = Logger.getLogger(VolumeUtil.class);
 
-  public static boolean isActiveVolume(Path dir) {
+  private static boolean isActiveVolume(Path dir) {
 
     // consider relative path as active and take no action
     if (!dir.toString().contains(":"))
@@ -64,15 +68,15 @@ public class VolumeUtil {
     return false;
   }
 
-  public static String removeSlash(String path) {
+  public static String removeTrailingSlash(String path) {
     while (path.endsWith("/"))
       path = path.substring(0, path.length() - 1);
     return path;
   }
 
-  public static Path removeSlash(Path path) {
+  public static Path removeTrailingSlash(Path path) {
     if (path.toString().endsWith("/"))
-      return new Path(removeSlash(path.toString()));
+      return new Path(removeTrailingSlash(path.toString()));
     return path;
   }
 
@@ -83,10 +87,10 @@ public class VolumeUtil {
     Path p = new Path(path);
 
     // removing slash because new Path("hdfs://nn1").equals(new 
Path("hdfs://nn1/")) evaluates to false
-    Path volume = removeSlash(ft.getVolume(p));
+    Path volume = removeTrailingSlash(ft.getVolume(p));
 
     for (Pair<Path,Path> pair : replacements) {
-      Path key = removeSlash(pair.getFirst());
+      Path key = removeTrailingSlash(pair.getFirst());
 
       if (key.equals(volume))
         return new Path(pair.getSecond(), ft.removeVolume(p)).toString();
@@ -142,9 +146,10 @@ public class VolumeUtil {
     }
   }
 
+
   public static Text switchRootTabletVolume(KeyExtent extent, Text location) 
throws IOException {
     if (extent.isRootTablet()) {
-      String newLocation = VolumeUtil.switchVolume(location.toString(), 
FileType.TABLE, ServerConstants.getVolumeReplacements());
+      String newLocation = switchVolume(location.toString(), FileType.TABLE, 
ServerConstants.getVolumeReplacements());
       if (newLocation != null) {
         MetadataTableUtil.setRootTabletDir(newLocation);
         log.info("Volume replaced " + extent + " : " + location + " -> " + 
newLocation);
@@ -154,7 +159,10 @@ public class VolumeUtil {
     return location;
   }
 
-  // Change volumes used by tablet based on configuration changes
+  /**
+   * This method does two things. First, it switches any volumes a tablet is 
using that are configured in instance.volumes.replacements. Second, if a tablet 
dir
+   * is no longer configured for use it chooses a new tablet directory.
+   */
   public static TabletFiles updateTabletVolumes(ZooLock zooLock, VolumeManager 
vm, KeyExtent extent, TabletFiles tabletFiles) throws IOException {
     List<Pair<Path,Path>> replacements = 
ServerConstants.getVolumeReplacements();
 
@@ -214,7 +222,7 @@ public class VolumeUtil {
 
   }
 
-  public static String decommisionedTabletDir(ZooLock zooLock, VolumeManager 
vm, KeyExtent extent, String metaDir) throws IOException {
+  private static String decommisionedTabletDir(ZooLock zooLock, VolumeManager 
vm, KeyExtent extent, String metaDir) throws IOException {
     Path dir = new Path(metaDir);
     if (isActiveVolume(dir))
       return metaDir;

Reply via email to