accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [02/23] git commit: ACCUMULO-2061 Fix up ServerConstants and make ChangeSecret reset the instanceId on all Volumes
Date Tue, 11 Mar 2014 18:25:11 GMT
ACCUMULO-2061 Fix up ServerConstants and make ChangeSecret reset the instanceId on all Volumes


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

Branch: refs/heads/ACCUMULO-2061
Commit: 0c841568ee715951d3ebc889c105d55328e8144b
Parents: 43a7ebd
Author: Josh Elser <elserj@apache.org>
Authored: Fri Mar 7 16:35:43 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Fri Mar 7 16:37:33 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/core/volume/Volume.java   |  7 +++++++
 .../apache/accumulo/core/volume/VolumeImpl.java   | 17 +++++------------
 .../java/org/apache/accumulo/server/Accumulo.java | 11 +++++++----
 .../apache/accumulo/server/ServerConstants.java   |  9 +++++----
 .../apache/accumulo/server/fs/VolumeManager.java  |  6 ++++++
 .../accumulo/server/fs/VolumeManagerImpl.java     | 10 ++++++++++
 .../apache/accumulo/server/util/ChangeSecret.java | 18 +++++++++++-------
 7 files changed, 51 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c841568/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/volume/Volume.java b/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
index 9dd7b16..08f61d4 100644
--- a/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
+++ b/core/src/main/java/org/apache/accumulo/core/volume/Volume.java
@@ -45,6 +45,13 @@ public interface Volume {
   public Path prefixChild(Path p);
 
   /**
+   * Convert the given child path into a Path that is relative to the base path for this
Volume
+   * @param p
+   * @return
+   */
+  public Path prefixChild(String p);
+
+  /**
    * Determine if the Path is valid on this Volume (contained by the basePath)
    * @param p
    * @return True if path is contained within the basePath, false otherwise

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c841568/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java b/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
index 65740ce..0aaf482 100644
--- a/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/volume/VolumeImpl.java
@@ -48,33 +48,21 @@ public class VolumeImpl implements Volume {
     this.basePath = basePath;
   }
   
-  /* (non-javadoc)
-   * @see org.apache.accumulo.core.volume.Volume#getFileSystem()
-   */
   @Override
   public FileSystem getFileSystem() {
     return fs;
   }
 
-  /* (non-javadoc)
-   * @see org.apache.accumulo.core.volume.Volume#getBasePath()
-   */
   @Override
   public String getBasePath() {
     return basePath;
   }
 
-  /* (non-javadoc)
-   * @see org.apache.accumulo.core.volume.Volume#prefixChild(Path)
-   */
   @Override
   public Path prefixChild(Path p) {
     return new Path(basePath, p);
   }
 
-  /* (non-javadoc)
-   * @see org.apache.accumulo.core.volume.Volume#isValidPath(Path)
-   */
   @Override
   public boolean isValidPath(Path p) {
     checkNotNull(p);
@@ -97,4 +85,9 @@ public class VolumeImpl implements Volume {
     return getFileSystem() + " " + basePath;
   }
 
+  @Override
+  public Path prefixChild(String p) {
+    return new Path(basePath, p);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c841568/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
index 2fa9051..fe1729c 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/Accumulo.java
@@ -31,6 +31,7 @@ import org.apache.accumulo.core.trace.DistributedTrace;
 import org.apache.accumulo.core.util.AddressUtil;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.util.Version;
+import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.conf.ServerConfiguration;
 import org.apache.accumulo.server.fs.VolumeManager;
@@ -50,10 +51,11 @@ public class Accumulo {
   private static final Logger log = Logger.getLogger(Accumulo.class);
   
   public static synchronized void updateAccumuloVersion(VolumeManager fs) {
+    Volume defaultVolume = fs.getDefaultVolume();
     try {
       if (getAccumuloPersistentVersion(fs) == ServerConstants.PREV_DATA_VERSION) {
-        fs.create(new Path(ServerConstants.getDataVersionLocation() + "/" + ServerConstants.DATA_VERSION));
-        fs.delete(new Path(ServerConstants.getDataVersionLocation() + "/" + ServerConstants.PREV_DATA_VERSION));
+        fs.create(new Path(ServerConstants.getDataVersionLocation(defaultVolume), Integer.toString(ServerConstants.DATA_VERSION)));
+        fs.delete(new Path(ServerConstants.getDataVersionLocation(defaultVolume), Integer.toString(ServerConstants.PREV_DATA_VERSION)));
       }
     } catch (IOException e) {
       throw new RuntimeException("Unable to set accumulo version: an error occurred.", e);
@@ -76,8 +78,9 @@ public class Accumulo {
   }
   
   public static synchronized int getAccumuloPersistentVersion(VolumeManager fs) {
-    Path path = ServerConstants.getDataVersionLocation();
-    return getAccumuloPersistentVersion(fs.getFileSystemByPath(path), path);
+    Volume defaultVolume = fs.getDefaultVolume();
+    Path path = ServerConstants.getDataVersionLocation(defaultVolume);
+    return getAccumuloPersistentVersion(defaultVolume.getFileSystem(), path);
   }
 
   public static void enableTracing(String address, String application) {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c841568/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 6ea3b91..6c27897 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
@@ -27,6 +27,7 @@ import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.util.CachedConfiguration;
 import org.apache.accumulo.core.util.Pair;
+import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.core.volume.VolumeConfiguration;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.server.conf.ServerConfiguration;
@@ -127,14 +128,14 @@ public class ServerConstants {
     return VolumeConfiguration.prefix(getBaseUris(), "walogArchive");
   }
 
-  public static Path getInstanceIdLocation() {
+  public static Path getInstanceIdLocation(Volume v) {
     // all base dirs should have the same instance id, so can choose any one
-    return new Path(getBaseUris()[0], INSTANCE_ID_DIR);
+    return v.prefixChild(INSTANCE_ID_DIR);
   }
 
-  public static Path getDataVersionLocation() {
+  public static Path getDataVersionLocation(Volume v) {
     // all base dirs should have the same version, so can choose any one
-    return new Path(getBaseUris()[0], VERSION_DIR);
+    return v.prefixChild(VERSION_DIR);
   }
 
   public static String[] getMetadataTableDirs() {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c841568/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java
index ce37058..2f7cf42 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManager.java
@@ -17,6 +17,7 @@
 package org.apache.accumulo.server.fs;
 
 import java.io.IOException;
+import java.util.Collection;
 
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.volume.Volume;
@@ -155,4 +156,9 @@ public interface VolumeManager {
 
   // decide on which of the given locations to create a new file
   String choose(String[] options);
+  
+  public Volume getDefaultVolume();
+  
+  public Collection<Volume> getVolumes();
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c841568/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
index 9b62ce3..e19182d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/VolumeManagerImpl.java
@@ -546,4 +546,14 @@ public class VolumeManagerImpl implements VolumeManager {
     return chooser.choose(options);
   }
 
+  @Override
+  public Volume getDefaultVolume() {
+    return defaultVolume;
+  }
+  
+  @Override
+  public Collection<Volume> getVolumes() {
+    return volumesByName.values();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/0c841568/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java b/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java
index ac13034..3f33a0e 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/ChangeSecret.java
@@ -24,7 +24,7 @@ import java.util.UUID;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.util.CachedConfiguration;
+import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
 import org.apache.accumulo.fate.zookeeper.ZooReader;
@@ -32,8 +32,9 @@ import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
 import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.cli.ClientOpts;
+import org.apache.accumulo.server.fs.VolumeManager;
+import org.apache.accumulo.server.fs.VolumeManagerImpl;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
-import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.ACL;
@@ -57,7 +58,7 @@ public class ChangeSecret {
     argsList.add("--new");
     argsList.addAll(Arrays.asList(args));
     opts.parseArgs(ChangeSecret.class.getName(), argsList.toArray(new String[0]));
-    FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
+    VolumeManager fs = VolumeManagerImpl.get();
     Instance inst = opts.getInstance();
     if (!verifyAccumuloIsDown(inst, opts.oldPass))
       System.exit(-1);
@@ -142,10 +143,13 @@ public class ChangeSecret {
     return newInstanceId;
   }
   
-  private static void updateHdfs(FileSystem fs, Instance inst, String newInstanceId) throws
IOException {
-    fs.delete(ServerConstants.getInstanceIdLocation(), true);
-    fs.mkdirs(ServerConstants.getInstanceIdLocation());
-    fs.create(new Path(ServerConstants.getInstanceIdLocation(), newInstanceId)).close();
+  private static void updateHdfs(VolumeManager fs, Instance inst, String newInstanceId) throws
IOException {
+    // Need to recreate the instanceId on all of them to keep consistency
+    for (Volume v : fs.getVolumes()) {
+      v.getFileSystem().delete(ServerConstants.getInstanceIdLocation(v), true);
+      v.getFileSystem().mkdirs(ServerConstants.getInstanceIdLocation(v));
+      v.getFileSystem().create(new Path(ServerConstants.getInstanceIdLocation(v), newInstanceId)).close();
+    }
   }
   
   private static void deleteInstance(Instance origInstance, String oldPass) throws Exception
{


Mime
View raw message