You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2017/08/02 16:41:26 UTC

accumulo git commit: ACCUMULO-4555 Removes parsing of version string in Version class

Repository: accumulo
Updated Branches:
  refs/heads/1.7 bf7bbb5b0 -> f2b9e2434


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.7
Commit: f2b9e2434ee398086218d91cae74de02daf73fe5
Parents: bf7bbb5
Author: Kyle <de...@gmail.com>
Authored: Fri Jul 28 09:58:46 2017 -0400
Committer: Mike Miller <mm...@apache.org>
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<String,String> sortedProps = new TreeMap<>();