Переглянути джерело

AMBARI-11386 Ambari Upgrade Error 2.0 -> 2.1 (dsen)

Dmytro Sen 10 роки тому
батько
коміт
b7f9b041f7

+ 3 - 8
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

@@ -4043,17 +4043,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
       widgetEntity.setMetrics(gson.toJson(layoutInfo.getMetricsInfo()));
       widgetEntity.setProperties(gson.toJson(layoutInfo.getProperties()));
       widgetEntity.setWidgetValues(gson.toJson(layoutInfo.getValues()));
+      widgetEntity.setListWidgetLayoutUserWidgetEntity(new LinkedList<WidgetLayoutUserWidgetEntity>());
       LOG.debug("Creating cluster widget with: name = " +
         layoutInfo.getWidgetName() + ", type = " + layoutInfo.getType() + ", " +
         "cluster = " + clusterEntity.getClusterName());
-      widgetDAO.create(widgetEntity);
-
-      createdEntities = widgetDAO.findByName(clusterEntity.getClusterId(), layoutInfo.getWidgetName(),
-              user, layoutInfo.getDefaultSectionName());
-      if (createdEntities != null && !createdEntities.isEmpty()) {
-        return createdEntities.iterator().next();
-      }
-
+      return widgetEntity;
     } else {
       LOG.warn("Skip creating widget from stack artifact since one or more " +
         "already exits with name = " + layoutInfo.getWidgetName() + ", " +
@@ -4101,6 +4095,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
               widgetLayoutUserWidgetEntity.setWidgetOrder(order++);
               widgetLayoutUserWidgetEntity.setWidgetLayout(layoutEntity);
               widgetLayoutUserWidgetEntityList.add(widgetLayoutUserWidgetEntity);
+              widgetEntity.getListWidgetLayoutUserWidgetEntity().add(widgetLayoutUserWidgetEntity);
             }
           }
           layoutEntity.setListWidgetLayoutUserWidgetEntity(widgetLayoutUserWidgetEntityList);

+ 2 - 1
ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog210.java

@@ -629,6 +629,7 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
     for (Long stackEntityId : stackEntityIds) {
       StackEntity stackEntity = stackDAO.findById(stackEntityId);
       String outdatedJson = entityToJsonMap.get(stackEntityId);
+      String outdatedRepoStack = MessageFormat.format("{0}-{1}",stackEntity.getStackName(),stackEntity.getStackVersion());
 
       String clustersSQL = MessageFormat.format(UPDATE_TEMPLATE, "clusters",
           DESIRED_STACK_ID_COLUMN_NAME, stackEntityId,
@@ -663,7 +664,7 @@ public class UpgradeCatalog210 extends AbstractUpgradeCatalog {
 
       String repoVersionSQL = MessageFormat.format(UPDATE_TEMPLATE,
           REPO_VERSION_TABLE, STACK_ID_COLUMN_NAME, stackEntityId, "stack",
-          outdatedJson);
+          outdatedRepoStack);
 
       dbAccessor.executeQuery(clustersSQL);
       dbAccessor.executeQuery(hostComponentDesiredStateSQL);