Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1AE87200CFD for ; Wed, 6 Sep 2017 22:27:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 196C81609C5; Wed, 6 Sep 2017 20:27:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 39E971609BA for ; Wed, 6 Sep 2017 22:27:57 +0200 (CEST) Received: (qmail 5445 invoked by uid 500); 6 Sep 2017 20:27:55 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 5436 invoked by uid 99); 6 Sep 2017 20:27:55 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Sep 2017 20:27:55 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id B6A07817BA; Wed, 6 Sep 2017 20:27:54 +0000 (UTC) Date: Wed, 06 Sep 2017 20:27:54 +0000 To: "commits@accumulo.apache.org" Subject: [accumulo] branch 1.7 updated: ACCUMULO-4686 Fix upgrade process to set version in all volumes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <150472967418.1968.10652519099985875498@gitbox.apache.org> From: ibella@apache.org Reply-To: "commits@accumulo.apache.org" X-Git-Host: gitbox.apache.org X-Git-Repo: accumulo X-Git-Refname: refs/heads/1.7 X-Git-Reftype: branch X-Git-Oldrev: 1bf6620e070146f37772651bf5ae21cf27e40718 X-Git-Newrev: bafeece4adfb6ea14587ed49d39f3be9777065bb X-Git-Rev: bafeece4adfb6ea14587ed49d39f3be9777065bb X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated archived-at: Wed, 06 Sep 2017 20:27:58 -0000 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 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" '].