ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-13930: Express Upgrade: Failure at Save Cluster State because cluster_version=OUT_OF_SYNC (jluniya)
Date Wed, 18 Nov 2015 19:58:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 b92ee5093 -> d01b1d806


AMBARI-13930: Express Upgrade: Failure at Save Cluster State because cluster_version=OUT_OF_SYNC
(jluniya)

Conflicts:
	ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java


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

Branch: refs/heads/branch-2.1
Commit: d01b1d80671ae6bfa4db2ed8d9ab23b04ba31f38
Parents: b92ee50
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Wed Nov 18 11:48:50 2015 -0800
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Wed Nov 18 11:56:45 2015 -0800

----------------------------------------------------------------------
 .../org/apache/ambari/server/api/handlers/CreateHandler.java | 4 ++--
 .../org/apache/ambari/server/state/cluster/ClusterImpl.java  | 8 ++++++++
 .../org/apache/ambari/server/state/cluster/ClusterTest.java  | 8 ++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d01b1d80/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
index c1bd91b..706d2be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/CreateHandler.java
@@ -54,7 +54,7 @@ public class CreateHandler extends BaseManagementHandler {
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e.getMessage()));
     } catch (SystemException e) {
       if (LOG.isErrorEnabled()) {
-        LOG.error("Caught a system exception while attempting to create a resource", e.getMessage());
+        LOG.error("Caught a system exception while attempting to create a resource: {}",
e.getMessage(), e);
       }
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e.getMessage()));
     } catch (ResourceAlreadyExistsException e) {
@@ -63,7 +63,7 @@ public class CreateHandler extends BaseManagementHandler {
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e.getMessage()));
     } catch (RuntimeException e) {
       if (LOG.isErrorEnabled()) {
-        LOG.error("Caught a runtime exception while attempting to create a resource", e);
+        LOG.error("Caught a runtime exception while attempting to create a resource: {}",
e.getMessage(), e);
       }
       //result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e.getMessage()));
       throw e;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d01b1d80/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 79cc1cc..f828a15 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -1221,6 +1221,7 @@ public class ClusterImpl implements Cluster {
    * UPGRADE_FAILED: at least one host in UPGRADE_FAILED
    * UPGRADED: all hosts are UPGRADED
    * UPGRADING: at least one host is UPGRADING, and the rest in UPGRADING|INSTALLED
+   * UPGRADING: at least one host is UPGRADED, and the rest in UPGRADING|INSTALLED
    * INSTALLED: all hosts in INSTALLED
    * INSTALL_FAILED: at least one host in INSTALL_FAILED
    * INSTALLING: all hosts in INSTALLING. Notice that if one host is CURRENT and another
is INSTALLING, then the
@@ -1251,6 +1252,13 @@ public class ClusterImpl implements Cluster {
     if (stateToHosts.containsKey(RepositoryVersionState.UPGRADING) && !stateToHosts.get(RepositoryVersionState.UPGRADING).isEmpty())
{
       return RepositoryVersionState.UPGRADING;
     }
+    if (stateToHosts.containsKey(RepositoryVersionState.UPGRADED)
+        && !stateToHosts.get(RepositoryVersionState.UPGRADED).isEmpty()
+        && stateToHosts.get(RepositoryVersionState.UPGRADED).size() != totalHosts)
{
+      // It is possible that a host has transitioned to UPGRADED state even before any other
host has transitioned to UPGRADING state.
+      // Example: Host with single component ZOOKEEPER Server on it which is the first component
to be upgraded.
+      return RepositoryVersionState.UPGRADING;
+    }
     if (stateToHosts.containsKey(RepositoryVersionState.INSTALLED) && stateToHosts.get(RepositoryVersionState.INSTALLED).size()
== totalHosts) {
       return RepositoryVersionState.INSTALLED;
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d01b1d80/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
index 28ba0e7..b2e2d68 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
@@ -1673,6 +1673,14 @@ public class ClusterTest {
     checkStackVersionState(stackId, stackVersion,
         RepositoryVersionState.UPGRADING);
 
+    hv1.setState(RepositoryVersionState.UPGRADED);
+    hostVersionDAO.merge(hv1);
+    c1.recalculateClusterVersionState(repositoryVersionEntity);
+    checkStackVersionState(stackId, stackVersion,
+        RepositoryVersionState.UPGRADING);
+    // reset host1 state
+    hv1.setState(RepositoryVersionState.UPGRADING);
+
     hv2.setState(RepositoryVersionState.UPGRADING);
     hostVersionDAO.merge(hv2);
     c1.recalculateClusterVersionState(repositoryVersionEntity);


Mime
View raw message