You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2016/03/14 20:52:18 UTC

ambari git commit: Revert "AMBARI-15348 Ambari upgrade/start commands should detect any ambari-server hotfix and fail upgrade/start from proceeding (dsen)"

Repository: ambari
Updated Branches:
  refs/heads/trunk b9d06931a -> b99085b7c


Revert "AMBARI-15348 Ambari upgrade/start commands should detect any ambari-server hotfix and fail upgrade/start from proceeding (dsen)"

This reverts commit 2b596be9b93682ed436837f4f2b75197ae4349c7.


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b99085b7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b99085b7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b99085b7

Branch: refs/heads/trunk
Commit: b99085b7c1beb78896e98f0d39f94eafb9c26afb
Parents: b9d0693
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Mon Mar 14 15:51:58 2016 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Mar 14 15:51:58 2016 -0400

----------------------------------------------------------------------
 ambari-server/pom.xml                           |  4 ++
 .../src/main/package/deb/control/preinst        | 14 -----
 .../src/main/package/rpm/preinstall.sh          | 14 -----
 .../python/ambari_server/serverClassPath.py     | 60 ++++--------------
 .../src/test/python/TestServerClassPath.py      | 66 +-------------------
 5 files changed, 16 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b99085b7/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index 5bb3b98..83424c2 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -1006,6 +1006,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.ant</groupId>
+      <artifactId>ant</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ant</groupId>
       <artifactId>ant-launcher</artifactId>
     </dependency>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b99085b7/ambari-server/src/main/package/deb/control/preinst
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/deb/control/preinst b/ambari-server/src/main/package/deb/control/preinst
index 34af1c8..eb94f95 100644
--- a/ambari-server/src/main/package/deb/control/preinst
+++ b/ambari-server/src/main/package/deb/control/preinst
@@ -34,8 +34,6 @@ AMBARI_KRB_JAAS_LOGIN_FILE_OLD="$AMBARI_KRB_JAAS_LOGIN_FILE.rpmsave"
 AMBARI_VIEWS_FOLDER="${ROOT}/var/lib/ambari-server/resources/views"
 AMBARI_VIEWS_BACKUP_FOLDER="$AMBARI_VIEWS_FOLDER/backups"
 
-AMBARI_SERVER_JAR_FILES="/usr/lib/ambari-server/ambari-server-*.jar"
-AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER="/usr/lib/ambari-server-backups"
 SERVER_CONF_SAVE="${ROOT}/etc/ambari-server/conf.save"
 SERVER_CONF_SAVE_BACKUP="${ROOT}/etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save"
 
@@ -79,16 +77,4 @@ then
     cp -u $AMBARI_VIEWS_FOLDER/*.jar $AMBARI_VIEWS_BACKUP_FOLDER/
 fi
 
-for f in $AMBARI_SERVER_JAR_FILES;
-do
-    if [ -f "$f" ]
-    then
-        if [ ! -d "$AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER" ]
-        then
-            mkdir -p "$AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER"
-        fi
-        mv -f $f $AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER/
-    fi
-done
-
 exit 0

http://git-wip-us.apache.org/repos/asf/ambari/blob/b99085b7/ambari-server/src/main/package/rpm/preinstall.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/rpm/preinstall.sh b/ambari-server/src/main/package/rpm/preinstall.sh
index 6ed7444..a8e781e 100644
--- a/ambari-server/src/main/package/rpm/preinstall.sh
+++ b/ambari-server/src/main/package/rpm/preinstall.sh
@@ -24,8 +24,6 @@ COMMON_SERVICES_FOLDER_OLD="${ROOT}/var/lib/ambari-server/resources/common-servi
 AMBARI_VIEWS_FOLDER="${ROOT}/var/lib/ambari-server/resources/views"
 AMBARI_VIEWS_BACKUP_FOLDER="$AMBARI_VIEWS_FOLDER/backups"
 
-AMBARI_SERVER_JAR_FILES="/usr/lib/ambari-server/ambari-server-*.jar"
-AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER="/usr/lib/ambari-server-backups"
 SERVER_CONF_SAVE="${ROOT}/etc/ambari-server/conf.save"
 SERVER_CONF_SAVE_BACKUP="${ROOT}/etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save"
 
@@ -54,16 +52,4 @@ then
     cp -u $AMBARI_VIEWS_FOLDER/*.jar $AMBARI_VIEWS_BACKUP_FOLDER/
 fi
 
-for f in $AMBARI_SERVER_JAR_FILES;
-do
-    if [ -f "$f" ]
-    then
-        if [ ! -d "$AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER" ]
-        then
-            mkdir -p "$AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER"
-        fi
-        mv -f $f $AMBARI_SERVER_JAR_FILES_BACKUP_FOLDER/
-    fi
-done
-
 exit 0

http://git-wip-us.apache.org/repos/asf/ambari/blob/b99085b7/ambari-server/src/main/python/ambari_server/serverClassPath.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverClassPath.py b/ambari-server/src/main/python/ambari_server/serverClassPath.py
index d0e6795..d3ade3e 100644
--- a/ambari-server/src/main/python/ambari_server/serverClassPath.py
+++ b/ambari-server/src/main/python/ambari_server/serverClassPath.py
@@ -17,21 +17,26 @@ 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.
 '''
-import glob
 
+import datetime
+import glob
 import os
+import re
+import shutil
+import stat
+import string
+import sys
+import tempfile
 
 import ambari_server
-import re
-from ambari_commons.exceptions import FatalException
-from ambari_commons.logging_utils import print_info_msg, print_error_msg
+from ambari_commons.logging_utils import print_info_msg
 from resource_management.core.shell import quote_bash_args
 AMBARI_CONF_VAR = "AMBARI_CONF_DIR"
 SERVER_CLASSPATH_KEY = "SERVER_CLASSPATH"
 LIBRARY_PATH_KEY = "LD_LIBRARY_PATH"
 AMBARI_SERVER_LIB = "AMBARI_SERVER_LIB"
 JDBC_DRIVER_PATH_PROPERTY = "server.jdbc.driver.path"
-JAR_FILE_PATTERN = re.compile(r'^(.*)(-\d.*\.jar$)')
+
 
 
 class ServerClassPath():
@@ -89,7 +94,7 @@ class ServerClassPath():
 
   def get_full_ambari_classpath_escaped_for_shell(self):
     class_path = self._get_ambari_classpath()
-    self._validate_classpath(class_path)
+
     # When classpath is required we should also set native libs os env variable
     # This is required for some jdbc (ex. sqlAnywhere)
     self.set_native_libs_path()
@@ -108,46 +113,3 @@ class ServerClassPath():
           native_libs_path = os.environ[LIBRARY_PATH_KEY] + os.pathsep + native_libs_path
         os.environ[LIBRARY_PATH_KEY] = native_libs_path
 
-  def _validate_classpath(self, classpath):
-    """
-    Check if  java class path contains multiple versions of the same jar
-    archives, if yes - raise FatalException()
-
-    Keyword arguments:
-      classpath - java class path
-    """
-    jars = self._find_all_jars(classpath)
-    jar_names = {}
-
-    for jar in jars:
-      match = JAR_FILE_PATTERN.match(os.path.basename(jar))
-      if match:
-        for group in match.groups():
-          if group in jar_names:
-            err = "Multiple versions of {0}.jar found in java class path " \
-                  "({1} and {2}). \n Make sure that you include only one " \
-                  "{0}.jar in the java class path '{3}'."\
-                  .format(group, jar, jar_names[group], classpath)
-            raise FatalException(1, err)
-          else:
-            jar_names[group] = jar
-            break
-
-  def _find_all_jars(self, classpath):
-    """
-    Return the list of absolute paths to jars in classpath.
-    Raise FatalException() if classpath isn't set
-
-    Keyword arguments:
-      classpath - java class path
-    """
-    if classpath:
-      jars = []
-      for wildcard in classpath.split(os.pathsep):
-        for path in glob.glob(wildcard):
-          if os.path.isfile(path) and path.endswith(".jar"):
-            jars.append(path)
-      return jars
-    else:
-      raise FatalException(1, "No classpath specified.")
-    pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/b99085b7/ambari-server/src/test/python/TestServerClassPath.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestServerClassPath.py b/ambari-server/src/test/python/TestServerClassPath.py
index 291c82b..7ec36da 100644
--- a/ambari-server/src/test/python/TestServerClassPath.py
+++ b/ambari-server/src/test/python/TestServerClassPath.py
@@ -20,9 +20,6 @@ import os
 os.environ["ROOT"] = ""
 
 import os
-import shutil
-import tempfile
-from ambari_commons.exceptions import FatalException
 from mock.mock import patch, MagicMock
 from unittest import TestCase
 from ambari_server.properties import Properties
@@ -32,6 +29,7 @@ from ambari_server.serverClassPath import ServerClassPath, AMBARI_SERVER_LIB, SE
 
 class TestConfigs(TestCase):
 
+
   @patch("ambari_server.serverConfiguration.get_conf_dir")
   def test_server_class_path_default(self, get_conf_dir_mock):
     properties = Properties()
@@ -92,65 +90,3 @@ class TestConfigs(TestCase):
     actual_classpath = serverClassPath.get_full_ambari_classpath_escaped_for_shell()
     self.assertEquals(expected_classpath, actual_classpath)
 
-  @patch("ambari_server.serverConfiguration.get_conf_dir")
-  def test_server_class_path_find_all_jars(self, get_conf_dir_mock):
-    temp_dir = tempfile.mkdtemp()
-    sub_dir = tempfile.mkdtemp(dir=temp_dir)
-    serverClassPath = ServerClassPath(None, None)
-    jar0 = tempfile.NamedTemporaryFile(suffix='.jar')
-    jar1 = tempfile.NamedTemporaryFile(suffix='.jar', dir=temp_dir)
-    jar2 = tempfile.NamedTemporaryFile(suffix='.jar', dir=temp_dir)
-    jar3 = tempfile.NamedTemporaryFile(suffix='.jar', dir=sub_dir)
-    # test /dir/*:file.jar
-    classpath = str(temp_dir) + os.path.sep + "*" + os.path.pathsep + jar0.name
-    jars = serverClassPath._find_all_jars(classpath)
-    self.assertEqual(len(jars), 3)
-    self.assertTrue(jar0.name in jars)
-    self.assertTrue(jar1.name in jars)
-    self.assertTrue(jar2.name in jars)
-    self.assertFalse(jar3.name in jars)
-
-    # test no classpath specified
-    try:
-      serverClassPath._find_all_jars(None)
-      self.fail()
-    except FatalException as fe:
-      pass
-
-    shutil.rmtree(temp_dir)
-
-  @patch.object(ServerClassPath, "_find_all_jars")
-  @patch("ambari_server.serverConfiguration.get_conf_dir")
-  def test_server_class_path_validate_classpath(self, get_conf_dir_mock,
-                                                find_jars_mock):
-    serverClassPath = ServerClassPath(None, None)
-
-    # No jars
-    find_jars_mock.return_value = []
-    try:
-      serverClassPath._validate_classpath(None)
-    except:
-      self.fail()
-
-    # Correct jars list
-    find_jars_mock.return_value = ["ambari-metrics-common-2.1.1.236.jar",
-                                   "ambari-server-2.1.1.236.jar",
-                                   "jetty-client-8.1.17.v20150415.jar",
-                                   "spring-core-3.0.7.RELEASE.jar"]
-    try:
-      serverClassPath._validate_classpath(None)
-    except:
-      self.fail()
-
-    # Incorrect jars list
-    find_jars_mock.return_value = ["ambari-metrics-common-2.1.1.236.jar",
-                                   "ambari-server-2.1.1.236.jar",
-                                   "ambari-server-2.1.1.hotfixed.jar",
-                                   "jetty-client-8.1.17.v20150415.jar",
-                                   "spring-core-3.0.7.RELEASE.jar"]
-    try:
-      serverClassPath._validate_classpath(None)
-      self.fail()
-    except:
-      pass
-