accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [04/11] git commit: ACCUMULO-2988 Add check for older versions
Date Thu, 31 Jul 2014 16:33:18 GMT
ACCUMULO-2988 Add check for older versions

We need to detect
That the version is one four
To do an upgrade


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

Branch: refs/heads/master
Commit: 35b524d27e6a42eabf4b55090a8fb47acf71ecb1
Parents: ceb1a74
Author: Mike Drob <mdrob@cloudera.com>
Authored: Fri May 2 11:36:06 2014 -0400
Committer: Sean Busbey <busbey@cloudera.com>
Committed: Thu Jul 31 11:30:57 2014 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/accumulo/server/Accumulo.java    | 10 +++++++---
 .../java/org/apache/accumulo/server/ServerConstants.java  |  1 +
 .../src/main/java/org/apache/accumulo/master/Master.java  |  5 +++--
 3 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/35b524d2/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 68d862d..841f1d5 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
@@ -56,14 +56,18 @@ public class Accumulo {
   private static final Logger log = Logger.getLogger(Accumulo.class);
   
   public static synchronized void updateAccumuloVersion(VolumeManager fs) {
+    updateAccumuloVersion(fs, ServerConstants.PREV_DATA_VERSION);
+  }
+
+  public static synchronized void updateAccumuloVersion(VolumeManager fs, int oldVersion)
{
     for (Volume volume : fs.getVolumes()) {
       try {
-        if (getAccumuloPersistentVersion(fs) == ServerConstants.PREV_DATA_VERSION) {
+        if (getAccumuloPersistentVersion(fs) == oldVersion) {
           log.debug("Attempting to upgrade " + volume);
           Path dataVersionLocation = ServerConstants.getDataVersionLocation(volume);
           fs.create(new Path(dataVersionLocation, Integer.toString(ServerConstants.DATA_VERSION))).close();
           // TODO document failure mode & recovery if FS permissions cause above to work
and below to fail ACCUMULO-2596
-          Path prevDataVersionLoc = new Path(dataVersionLocation, Integer.toString(ServerConstants.PREV_DATA_VERSION));
+          Path prevDataVersionLoc = new Path(dataVersionLocation, Integer.toString(oldVersion));
           if (!fs.delete(prevDataVersionLoc)) {
             throw new RuntimeException("Could not delete previous data version location ("
+ prevDataVersionLoc + ") for " + volume);
           }
@@ -176,7 +180,7 @@ public class Accumulo {
     Accumulo.waitForZookeeperAndHdfs(fs);
     
     Version codeVersion = new Version(Constants.VERSION);
-    if (dataVersion != ServerConstants.DATA_VERSION && dataVersion != ServerConstants.PREV_DATA_VERSION)
{
+    if (dataVersion != ServerConstants.DATA_VERSION && dataVersion != ServerConstants.PREV_DATA_VERSION
&& dataVersion != ServerConstants.TWO_VERSIONS_AGO) {
       throw new RuntimeException("This version of accumulo (" + codeVersion + ") is not compatible
with files stored using data version " + dataVersion);
     }
     

http://git-wip-us.apache.org/repos/asf/accumulo/blob/35b524d2/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 b577abb..6f9d0c9 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
@@ -51,6 +51,7 @@ public class ServerConstants {
    */
   public static final int DATA_VERSION = 6;
   public static final int PREV_DATA_VERSION = 5;
+  public static final int TWO_VERSIONS_AGO = 4;
 
   private static String[] baseUris = null;
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/35b524d2/server/master/src/main/java/org/apache/accumulo/master/Master.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index c367ae0..b7d7784 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -349,7 +349,8 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
   private void upgradeMetadata() {
     // we make sure we're only doing the rest of this method once so that we can signal to
other threads that an upgrade wasn't needed.
     if (upgradeMetadataRunning.compareAndSet(false, true)) {
-      if (Accumulo.getAccumuloPersistentVersion(fs) == ServerConstants.PREV_DATA_VERSION)
{
+      final int accumuloPersistentVersion = Accumulo.getAccumuloPersistentVersion(fs);
+      if (accumuloPersistentVersion == ServerConstants.TWO_VERSIONS_AGO || accumuloPersistentVersion
== ServerConstants.PREV_DATA_VERSION) {
         // sanity check that we passed the Fate verification prior to ZooKeeper upgrade,
and that Fate still hasn't been started.
         // Change both to use Guava's Verify once we use Guava 17.
         if (!haveUpgradedZooKeeper) {
@@ -365,7 +366,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
               log.info("Starting to upgrade !METADATA table.");
               MetadataTableUtil.moveMetaDeleteMarkers(instance, SystemCredentials.get());
               log.info("Updating persistent data version.");
-              Accumulo.updateAccumuloVersion(fs);
+              Accumulo.updateAccumuloVersion(fs, accumuloPersistentVersion);
               log.info("Upgrade complete");
               waitForMetadataUpgrade.countDown();
             } catch (Exception ex) {


Mime
View raw message