ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [40/50] [abbrv] ambari git commit: AMBARI-18441 - upgrade ambari to 2.1.1 error (Wang Yaoxin via jonathanhurley)
Date Fri, 02 Dec 2016 20:26:38 GMT
AMBARI-18441 - upgrade ambari to 2.1.1 error (Wang Yaoxin via jonathanhurley)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: ae3ff2a09b6b36f8a456987c60fc695dd262b6bb
Parents: 80084a9
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Fri Dec 2 10:13:22 2016 -0500
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Fri Dec 2 10:13:45 2016 -0500

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog211.java       | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ff2a0/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java
index db13612..eb835ef 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog211.java
@@ -212,8 +212,8 @@ public class UpgradeCatalog211 extends AbstractUpgradeCatalog {
         statement = dbAccessor.getConnection().createStatement();
         if (statement != null) {
           String selectSQL = MessageFormat.format(
-              "SELECT cluster_id, service_name, component_name, host_id FROM {0}",
-              HOST_COMPONENT_STATE_TABLE);
+              "SELECT id, cluster_id, service_name, component_name, host_id FROM {0} ORDER
BY {1} {2}",
+              HOST_COMPONENT_STATE_TABLE, "id", "DESC");
 
           resultSet = statement.executeQuery(selectSQL);
           while (resultSet.next()) {
@@ -221,13 +221,19 @@ public class UpgradeCatalog211 extends AbstractUpgradeCatalog {
             final String serviceName = resultSet.getString("service_name");
             final String componentName = resultSet.getString("component_name");
             final Long hostId = resultSet.getLong("host_id");
-
-            String updateSQL = MessageFormat.format(
-                "UPDATE {0} SET {1} = {2,number,#} WHERE cluster_id = {3} AND service_name
= ''{4}'' AND component_name = ''{5}'' and host_id = {6,number,#}",
-                HOST_COMPONENT_STATE_TABLE, HOST_COMPONENT_STATE_ID_COLUMN, m_hcsId.getAndIncrement(),
-                clusterId, serviceName, componentName, hostId);
-
-            dbAccessor.executeQuery(updateSQL);
+            final Long idKey = resultSet.getLong("id");
+
+            if (idKey != 0 && m_hcsId.get() == 1) {
+              m_hcsId.set(idKey);
+              m_hcsId.getAndIncrement();
+            } else if(idKey == 0) {
+              String updateSQL = MessageFormat.format(
+                  "UPDATE {0} SET {1} = {2,number,#} WHERE cluster_id = {3} AND service_name
= ''{4}'' AND component_name = ''{5}'' and host_id = {6,number,#}",
+                  HOST_COMPONENT_STATE_TABLE, HOST_COMPONENT_STATE_ID_COLUMN, m_hcsId.getAndIncrement(),
+                  clusterId, serviceName, componentName, hostId);
+
+              dbAccessor.executeQuery(updateSQL);
+            }
           }
         }
       } finally {


Mime
View raw message