ACCUMULO-2451 Update the data version on all volumes instead of just one
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d45b723f Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d45b723f Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d45b723f Branch: refs/heads/master Commit: d45b723f0df73fa3f24d9911da44481615c7298b Parents: 7c94c08 Author: Josh Elser <els...@apache.org> Authored: Wed Mar 12 12:10:44 2014 -0400 Committer: Josh Elser <els...@apache.org> Committed: Thu Mar 20 18:58:41 2014 -0400 ---------------------------------------------------------------------- .../org/apache/accumulo/server/Accumulo.java | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/d45b723f/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 48534f0..f7f2298 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 @@ -51,15 +51,21 @@ public class Accumulo { private static final Logger log = Logger.getLogger(Accumulo.class); public static synchronized void updateAccumuloVersion(VolumeManager fs) { - // TODO ACCUMULO-2451 Should update all volumes, not one - Volume volume = fs.getVolumes().iterator().next(); - try { - if (getAccumuloPersistentVersion(fs) == ServerConstants.PREV_DATA_VERSION) { - fs.create(new Path(ServerConstants.getDataVersionLocation(volume), Integer.toString(ServerConstants.DATA_VERSION))); - fs.delete(new Path(ServerConstants.getDataVersionLocation(volume), Integer.toString(ServerConstants.PREV_DATA_VERSION))); + for (Volume volume : fs.getVolumes()) { + try { + if (getAccumuloPersistentVersion(fs) == ServerConstants.PREV_DATA_VERSION) { + log.debug("Attempting to upgrade " + volume); + Path dataVersionLocation = ServerConstants.getDataVersionLocation(volume); + fs.create(new Path(dataVersionLocation, Integer.toString(ServerConstants.DATA_VERSION))).close(); + + Path prevDataVersionLoc = new Path(dataVersionLocation, Integer.toString(ServerConstants.PREV_DATA_VERSION)); + if (!fs.delete(prevDataVersionLoc)) { + throw new RuntimeException("Could not delete previous data version location (" + prevDataVersionLoc + ") for " + volume); + } + } + } catch (IOException e) { + throw new RuntimeException("Unable to set accumulo version: an error occurred.", e); } - } catch (IOException e) { - throw new RuntimeException("Unable to set accumulo version: an error occurred.", e); } }