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 46870200CE7 for ; Wed, 2 Aug 2017 18:40:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4595116924B; Wed, 2 Aug 2017 16:40: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 6440C168D17 for ; Wed, 2 Aug 2017 18:40:57 +0200 (CEST) Received: (qmail 21980 invoked by uid 500); 2 Aug 2017 16:40:51 -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 21026 invoked by uid 99); 2 Aug 2017 16:40:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2017 16:40:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 14709DFDDD; Wed, 2 Aug 2017 16:40:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mmiller@apache.org To: commits@accumulo.apache.org Date: Wed, 02 Aug 2017 16:40:50 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] accumulo git commit: ACCUMULO-4555 Removes parsing of version string in Version class archived-at: Wed, 02 Aug 2017 16:40:58 -0000 Repository: accumulo Updated Branches: refs/heads/1.8 591ba9f90 -> 5da9a3afa ACCUMULO-4555 Removes parsing of version string in Version class This fix removes the extraneous parsing code, constructors, and methods from the Version class, keeping only the KeywordExecutable portions. Updated Accumulo class as well removing dependency on Version class. Removes old TestVersion unit test based on PR feedback. Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/f2b9e243 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/f2b9e243 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/f2b9e243 Branch: refs/heads/1.8 Commit: f2b9e2434ee398086218d91cae74de02daf73fe5 Parents: bf7bbb5 Author: Kyle Authored: Fri Jul 28 09:58:46 2017 -0400 Committer: Mike Miller Committed: Wed Aug 2 12:02:43 2017 -0400 ---------------------------------------------------------------------- .../org/apache/accumulo/core/util/Version.java | 73 -------------------- .../apache/accumulo/core/util/TestVersion.java | 64 ----------------- .../org/apache/accumulo/server/Accumulo.java | 4 +- 3 files changed, 1 insertion(+), 140 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/f2b9e243/core/src/main/java/org/apache/accumulo/core/util/Version.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/Version.java b/core/src/main/java/org/apache/accumulo/core/util/Version.java index f3d8bfb..c5d23fe 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/Version.java +++ b/core/src/main/java/org/apache/accumulo/core/util/Version.java @@ -16,9 +16,6 @@ */ package org.apache.accumulo.core.util; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.apache.accumulo.start.Main; import org.apache.accumulo.start.spi.KeywordExecutable; @@ -27,8 +24,6 @@ import com.google.auto.service.AutoService; @AutoService(KeywordExecutable.class) public class Version implements KeywordExecutable { - public Version() {} - @Override public String keyword() { return "version"; @@ -40,72 +35,4 @@ public class Version implements KeywordExecutable { System.out.println(runTMP.getField("VERSION").get(null)); } - String package_ = null; - int major = 0; - int minor = 0; - int release = 0; - String etcetera = null; - - public Version(String everything) { - parse(everything); - } - - private void parse(String everything) { - Pattern pattern = Pattern.compile("(([^-]*)-)?(\\d+)(\\.(\\d+)(\\.(\\d+))?)?(-(.*))?"); - Matcher parser = pattern.matcher(everything); - if (!parser.matches()) - throw new IllegalArgumentException("Unable to parse: " + everything + " as a version"); - - if (parser.group(1) != null) - package_ = parser.group(2); - major = Integer.parseInt(parser.group(3)); - minor = 0; - if (parser.group(5) != null) - minor = Integer.parseInt(parser.group(5)); - if (parser.group(7) != null) - release = Integer.parseInt(parser.group(7)); - if (parser.group(9) != null) - etcetera = parser.group(9); - - } - - public String getPackage() { - return package_; - } - - public int getMajorVersion() { - return major; - } - - public int getMinorVersion() { - return minor; - } - - public int getReleaseVersion() { - return release; - } - - public String getEtcetera() { - return etcetera; - } - - @Override - public String toString() { - StringBuilder result = new StringBuilder(); - if (package_ != null) { - result.append(package_); - result.append("-"); - } - result.append(major); - result.append("."); - result.append(minor); - result.append("."); - result.append(release); - if (etcetera != null) { - result.append("-"); - result.append(etcetera); - } - return result.toString(); - } - } http://git-wip-us.apache.org/repos/asf/accumulo/blob/f2b9e243/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java b/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java deleted file mode 100644 index af3f391..0000000 --- a/core/src/test/java/org/apache/accumulo/core/util/TestVersion.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.accumulo.core.util; - -import junit.framework.TestCase; - -public class TestVersion extends TestCase { - Version make(String version) { - return new Version(version); - } - - public void testOne() { - Version v; - - v = make("abc-1.2.3-ugly"); - assertTrue(v != null); - assertTrue(v.getPackage().equals("abc")); - assertTrue(v.getMajorVersion() == 1); - assertTrue(v.getMinorVersion() == 2); - assertTrue(v.getReleaseVersion() == 3); - assertTrue(v.getEtcetera().equals("ugly")); - - v = make("3.2.1"); - assertTrue(v.getPackage() == null); - assertTrue(v.getMajorVersion() == 3); - assertTrue(v.getMinorVersion() == 2); - assertTrue(v.getReleaseVersion() == 1); - assertTrue(v.getEtcetera() == null); - - v = make("55"); - assertTrue(v.getPackage() == null); - assertTrue(v.getMajorVersion() == 55); - assertTrue(v.getMinorVersion() == 0); - assertTrue(v.getReleaseVersion() == 0); - assertTrue(v.getEtcetera() == null); - - v = make("7.1-beta"); - assertTrue(v.getPackage() == null); - assertTrue(v.getMajorVersion() == 7); - assertTrue(v.getMinorVersion() == 1); - assertTrue(v.getReleaseVersion() == 0); - assertTrue(v.getEtcetera().equals("beta")); - - try { - make("beta"); - fail("Should have thrown an error"); - } catch (IllegalArgumentException t) {} - } - -} http://git-wip-us.apache.org/repos/asf/accumulo/blob/f2b9e243/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 1589e9d..e4c944f 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 @@ -35,7 +35,6 @@ import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.util.AddressUtil; import org.apache.accumulo.core.util.UtilWaitThread; -import org.apache.accumulo.core.util.Version; import org.apache.accumulo.core.volume.Volume; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.fate.ReadOnlyStore; @@ -175,9 +174,8 @@ public class Accumulo { log.info("Data Version " + dataVersion); Accumulo.waitForZookeeperAndHdfs(fs); - Version codeVersion = new Version(Constants.VERSION); if (!(canUpgradeFromDataVersion(dataVersion))) { - throw new RuntimeException("This version of accumulo (" + codeVersion + ") is not compatible with files stored using data version " + dataVersion); + throw new RuntimeException("This version of accumulo (" + Constants.VERSION + ") is not compatible with files stored using data version " + dataVersion); } TreeMap sortedProps = new TreeMap<>();