You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ib...@apache.org on 2017/09/06 20:27:54 UTC
[accumulo] branch 1.7 updated: ACCUMULO-4686 Fix upgrade process to
set version in all volumes.
This is an automated email from the ASF dual-hosted git repository.
ibella pushed a commit to branch 1.7
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/1.7 by this push:
new bafeece ACCUMULO-4686 Fix upgrade process to set version in all volumes.
bafeece is described below
commit bafeece4adfb6ea14587ed49d39f3be9777065bb
Author: Ivan Bella <iv...@bella.name>
AuthorDate: Fri Sep 1 14:51:53 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 e4c944f..e2441bd 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
@@ -61,7 +61,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();
@@ -92,13 +92,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 19b0a9b..7709a98 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
@@ -25,7 +25,11 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
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.commons.io.FileUtils;
+import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -87,6 +91,53 @@ public class AccumuloTest {
}
@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);
+ }
+
+ @Test
public void testLocateLogConfig() throws Exception {
File confDir = new File(FileUtils.getTempDirectory(), "AccumuloTest" + System.currentTimeMillis());
String confDirName = confDir.getAbsolutePath();
--
To stop receiving notification emails like this one, please contact
['"commits@accumulo.apache.org" <co...@accumulo.apache.org>'].