accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ibe...@apache.org
Subject [accumulo] branch master updated: ACCUMULO-4686 Fix upgrade process to set version in all volumes.
Date Wed, 06 Sep 2017 20:31:36 GMT
This is an automated email from the ASF dual-hosted git repository.

ibella pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new c7117b8  ACCUMULO-4686 Fix upgrade process to set version in all volumes.
c7117b8 is described below

commit c7117b8e6bc893b237cc6dd674ac02ffb78e116c
Author: Ivan Bella <ivan@bella.name>
AuthorDate: Wed Jul 26 13:52:01 2017 -0400

    ACCUMULO-4686 Fix upgrade process to set version in all volumes.
    
    The upgrade process was only setting the version in one of a multi-volume system.
    This fixes the code to set the version on all volumes.
---
 .../java/org/apache/accumulo/server/Accumulo.java  | 11 +++--
 .../org/apache/accumulo/server/AccumuloTest.java   | 51 ++++++++++++++++++++++
 2 files changed, 58 insertions(+), 4 deletions(-)

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 a73faf8..e0d9e22 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
@@ -59,7 +59,7 @@ public class Accumulo {
   public static synchronized void updateAccumuloVersion(VolumeManager fs, int oldVersion)
{
     for (Volume volume : fs.getVolumes()) {
       try {
-        if (getAccumuloPersistentVersion(fs) == oldVersion) {
+        if (getAccumuloPersistentVersion(volume) == oldVersion) {
           log.debug("Attempting to upgrade {}", volume);
           Path dataVersionLocation = ServerConstants.getDataVersionLocation(volume);
           fs.create(new Path(dataVersionLocation, Integer.toString(ServerConstants.DATA_VERSION))).close();
@@ -90,13 +90,16 @@ public class Accumulo {
     }
   }
 
-  public static synchronized int getAccumuloPersistentVersion(VolumeManager fs) {
-    // It doesn't matter which Volume is used as they should all have the data version stored
-    Volume v = fs.getVolumes().iterator().next();
+  public static synchronized int getAccumuloPersistentVersion(Volume v) {
     Path path = ServerConstants.getDataVersionLocation(v);
     return getAccumuloPersistentVersion(v.getFileSystem(), path);
   }
 
+  public static synchronized int getAccumuloPersistentVersion(VolumeManager fs) {
+    // It doesn't matter which Volume is used as they should all have the data version stored
+    return getAccumuloPersistentVersion(fs.getVolumes().iterator().next());
+  }
+
   public static synchronized Path getAccumuloInstanceIdPath(VolumeManager fs) {
     // It doesn't matter which Volume is used as they should all have the instance ID stored
     Volume v = fs.getVolumes().iterator().next();
diff --git a/server/base/src/test/java/org/apache/accumulo/server/AccumuloTest.java b/server/base/src/test/java/org/apache/accumulo/server/AccumuloTest.java
index 2d99058..aba9b36 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/AccumuloTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/AccumuloTest.java
@@ -23,6 +23,10 @@ import static org.junit.Assert.assertEquals;
 
 import java.io.FileNotFoundException;
 
+import com.google.common.collect.Sets;
+import org.apache.accumulo.core.volume.Volume;
+import org.apache.accumulo.server.fs.VolumeManager;
+import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -82,4 +86,51 @@ public class AccumuloTest {
 
     assertEquals(-1, Accumulo.getAccumuloPersistentVersion(fs, path));
   }
+
+  @Test
+  public void testUpdateAccumuloVersion() throws Exception {
+    Volume v1 = createMock(Volume.class);
+    FileSystem fs1 = createMock(FileSystem.class);
+    Path baseVersion1 = new Path("hdfs://volume1/accumulo/version");
+    Path oldVersion1 = new Path("hdfs://volume1/accumulo/version/7");
+    Path newVersion1 = new Path("hdfs://volume1/accumulo/version/" + Integer.toString(ServerConstants.DATA_VERSION));
+
+    FileStatus[] files1 = mockPersistentVersion("7");
+    expect(fs1.listStatus(baseVersion1)).andReturn(files1);
+    replay(fs1);
+
+    FSDataOutputStream fsdos1 = createMock(FSDataOutputStream.class);
+    expect(v1.getFileSystem()).andReturn(fs1);
+    expect(v1.prefixChild(ServerConstants.VERSION_DIR)).andReturn(baseVersion1).times(2);
+    replay(v1);
+    fsdos1.close();
+    replay(fsdos1);
+
+    Volume v2 = createMock(Volume.class);
+    FileSystem fs2 = createMock(FileSystem.class);
+    Path baseVersion2 = new Path("hdfs://volume2/accumulo/version");
+    Path oldVersion2 = new Path("hdfs://volume2/accumulo/version/7");
+    Path newVersion2 = new Path("hdfs://volume2/accumulo/version/" + Integer.toString(ServerConstants.DATA_VERSION));
+
+    FileStatus[] files2 = mockPersistentVersion("7");
+    expect(fs2.listStatus(baseVersion2)).andReturn(files2);
+    replay(fs2);
+
+    FSDataOutputStream fsdos2 = createMock(FSDataOutputStream.class);
+    expect(v2.getFileSystem()).andReturn(fs2);
+    expect(v2.prefixChild(ServerConstants.VERSION_DIR)).andReturn(baseVersion2).times(2);
+    replay(v2);
+    fsdos2.close();
+    replay(fsdos2);
+
+    VolumeManager vm = createMock(VolumeManager.class);
+    expect(vm.getVolumes()).andReturn(Sets.newHashSet(v1, v2));
+    expect(vm.delete(oldVersion1)).andReturn(true);
+    expect(vm.create(newVersion1)).andReturn(fsdos1);
+    expect(vm.delete(oldVersion2)).andReturn(true);
+    expect(vm.create(newVersion2)).andReturn(fsdos2);
+    replay(vm);
+
+    Accumulo.updateAccumuloVersion(vm, 7);
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@accumulo.apache.org" <commits@accumulo.apache.org>'].

Mime
View raw message