accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bus...@apache.org
Subject [06/11] git commit: ACCUMULO-2988 Clean up of upgrade related constants and checks.
Date Thu, 31 Jul 2014 16:33:20 GMT
ACCUMULO-2988 Clean up of upgrade related constants and checks.


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

Branch: refs/heads/master
Commit: 3a93bad37149792ebd33f641f164e6590c7573c7
Parents: 81e3d27
Author: Sean Busbey <busbey@cloudera.com>
Authored: Wed Jul 16 17:25:56 2014 -0500
Committer: Sean Busbey <busbey@cloudera.com>
Committed: Thu Jul 31 11:30:58 2014 -0500

----------------------------------------------------------------------
 .../org/apache/accumulo/server/Accumulo.java    | 21 +++++++++++++++-----
 .../apache/accumulo/server/ServerConstants.java |  2 +-
 .../java/org/apache/accumulo/master/Master.java | 18 ++++++++---------
 3 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3a93bad3/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 841f1d5..ca70efe 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
@@ -55,10 +55,6 @@ 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 {
@@ -180,7 +176,7 @@ public class Accumulo {
     Accumulo.waitForZookeeperAndHdfs(fs);
     
     Version codeVersion = new Version(Constants.VERSION);
-    if (dataVersion != ServerConstants.DATA_VERSION && dataVersion != ServerConstants.PREV_DATA_VERSION
&& dataVersion != ServerConstants.TWO_VERSIONS_AGO) {
+    if (!(canUpgradeFromDataVersion(dataVersion))) {
       throw new RuntimeException("This version of accumulo (" + codeVersion + ") is not compatible
with files stored using data version " + dataVersion);
     }
     
@@ -195,6 +191,21 @@ public class Accumulo {
     
     monitorSwappiness();
   }
+
+  /**
+   * Sanity check that the current persistent version is allowed to upgrade to the version
of Accumulo running.
+   * @param dataVersion the version that is persisted in the backing Volumes
+   */
+  public static boolean canUpgradeFromDataVersion(final int dataVersion) {
+    return dataVersion == ServerConstants.DATA_VERSION || dataVersion == ServerConstants.PREV_DATA_VERSION
|| dataVersion == ServerConstants.TWO_DATA_VERSIONS_AGO;
+  }
+
+  /**
+   * Does the data version number stored in the backing Volumes indicate we need to upgrade
something?
+   */
+  public static boolean persistentVersionNeedsUpgrade(final int accumuloPersistentVersion)
{
+    return accumuloPersistentVersion == ServerConstants.TWO_DATA_VERSIONS_AGO || accumuloPersistentVersion
== ServerConstants.PREV_DATA_VERSION;
+  }
   
   /**
    * 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3a93bad3/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 6f9d0c9..10a864c 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,7 +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;
+  public static final int TWO_DATA_VERSIONS_AGO = 4;
 
   private static String[] baseUris = null;
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3a93bad3/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 63acd62..30b1f2e 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
@@ -275,7 +275,7 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
     // that the master is not the only thing that may alter zookeeper before starting.
 
     final int accumuloPersistentVersion = Accumulo.getAccumuloPersistentVersion(fs);
-    if (accumuloPersistentVersion == ServerConstants.TWO_VERSIONS_AGO || accumuloPersistentVersion
== ServerConstants.PREV_DATA_VERSION) {
+    if (Accumulo.persistentVersionNeedsUpgrade(accumuloPersistentVersion)) {
       // This Master hasn't started Fate yet, so any outstanding transactions must be from
before the upgrade.
       // Change to Guava's Verify once we use Guava 17.
       if (null != fate) {
@@ -288,8 +288,8 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
         IZooReaderWriter zoo = ZooReaderWriter.getInstance();
         final String zooRoot = ZooUtil.getRoot(instance);
 
-        if (accumuloPersistentVersion == ServerConstants.TWO_VERSIONS_AGO) {
-          log.debug("Handling updates for version " + ServerConstants.TWO_VERSIONS_AGO);
+        if (accumuloPersistentVersion == ServerConstants.TWO_DATA_VERSIONS_AGO) {
+          log.debug("Handling updates for version " + ServerConstants.TWO_DATA_VERSIONS_AGO);
 
           log.debug("Cleaning out remnants of logger role.");
           zoo.recursiveDelete(zooRoot + "/loggers", NodeMissingPolicy.SKIP);
@@ -369,11 +369,11 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
     // 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)) {
       final int accumuloPersistentVersion = Accumulo.getAccumuloPersistentVersion(fs);
-      if (accumuloPersistentVersion == ServerConstants.TWO_VERSIONS_AGO || accumuloPersistentVersion
== ServerConstants.PREV_DATA_VERSION) {
+      if (Accumulo.persistentVersionNeedsUpgrade(accumuloPersistentVersion)) {
         // 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) {
-          throw new IllegalStateException("We should only attempt to upgrade Accumulo's !METADATA
table if we've already upgraded ZooKeeper. Please save all logs and file a bug.");
+          throw new IllegalStateException("We should only attempt to upgrade Accumulo's metadata
table if we've already upgraded ZooKeeper. Please save all logs and file a bug.");
         }
         if (null != fate) {
           throw new IllegalStateException("Access to Fate should not have been initialized
prior to the Master finishing upgrades. Please save all logs and file a bug.");
@@ -382,12 +382,12 @@ public class Master implements LiveTServerSet.Listener, TableObserver,
CurrentSt
           @Override
           public void run() {
             try {
-              log.info("Starting to upgrade !METADATA table.");
-              if (accumuloPersistentVersion == ServerConstants.TWO_VERSIONS_AGO) {
-                log.info("Updating Delete Markers in !METADATA table for version 1.4");
+              log.info("Starting to upgrade metadata table.");
+              if (accumuloPersistentVersion == ServerConstants.TWO_DATA_VERSIONS_AGO) {
+                log.info("Updating Delete Markers in metadata table for version 1.4");
                 MetadataTableUtil.moveMetaDeleteMarkersFrom14(instance, SystemCredentials.get());
               } else {
-                log.info("Updating Delete Markers in !METADATA table.");
+                log.info("Updating Delete Markers in metadata table.");
                 MetadataTableUtil.moveMetaDeleteMarkers(instance, SystemCredentials.get());
               }
               log.info("Updating persistent data version.");


Mime
View raw message