Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 eb52ddb89 -> e4f66cd95


AMBARI-18524 Kafka widget update needs UpgradeCatalog handling (dsen)


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

Branch: refs/heads/branch-2.5
Commit: e4f66cd95ca1074f2a155a19240e1874281c7b20
Parents: eb52ddb
Author: Dmytro Sen <[email protected]>
Authored: Mon Oct 24 13:24:00 2016 +0300
Committer: Dmytro Sen <[email protected]>
Committed: Mon Oct 24 13:27:17 2016 +0300

----------------------------------------------------------------------
 .../server/upgrade/AbstractUpgradeCatalog.java  |  98 +++++++++
 .../server/upgrade/SchemaUpgradeHelper.java     |   1 +
 .../server/upgrade/UpgradeCatalog222.java       |   2 +-
 .../server/upgrade/UpgradeCatalog240.java       |  83 --------
 .../server/upgrade/UpgradeCatalog2402.java      | 207 +++++++++++++++++++
 .../server/upgrade/UpgradeCatalog242.java       |   2 +-
 .../server/upgrade/UpgradeCatalog250.java       |   2 +-
 .../server/upgrade/UpgradeCatalog250Test.java   |   1 -
 8 files changed, 309 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
index 8187bc2..d3e5920 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
@@ -23,9 +23,11 @@ import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 
 import java.io.File;
+import java.io.FileReader;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.StringReader;
+import java.lang.reflect.Type;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
@@ -45,6 +47,8 @@ import java.util.TreeMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
@@ -54,6 +58,7 @@ import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.ArtifactDAO;
 import org.apache.ambari.server.orm.dao.MetainfoDAO;
+import org.apache.ambari.server.orm.dao.WidgetDAO;
 import org.apache.ambari.server.orm.dao.PermissionDAO;
 import org.apache.ambari.server.orm.dao.ResourceTypeDAO;
 import org.apache.ambari.server.orm.dao.RoleAuthorizationDAO;
@@ -62,6 +67,7 @@ import org.apache.ambari.server.orm.entities.ArtifactEntity;
 import org.apache.ambari.server.orm.entities.MetainfoEntity;
 import org.apache.ambari.server.orm.entities.PermissionEntity;
 import org.apache.ambari.server.orm.entities.RoleAuthorizationEntity;
+import org.apache.ambari.server.orm.entities.WidgetEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
@@ -70,12 +76,15 @@ import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.PropertyUpgradeBehavior;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.alert.SourceType;
 import 
org.apache.ambari.server.state.kerberos.AbstractKerberosDescriptorContainer;
 import org.apache.ambari.server.state.kerberos.KerberosDescriptor;
 import org.apache.ambari.server.state.kerberos.KerberosDescriptorFactory;
 import org.apache.ambari.server.state.kerberos.KerberosIdentityDescriptor;
 import org.apache.ambari.server.state.kerberos.KerberosServiceDescriptor;
+import org.apache.ambari.server.state.stack.WidgetLayout;
+import org.apache.ambari.server.state.stack.WidgetLayoutInfo;
 import org.apache.ambari.server.utils.VersionUtils;
 import org.apache.ambari.server.view.ViewArchiveUtility;
 import org.apache.ambari.server.view.configuration.ViewConfig;
@@ -1137,4 +1146,93 @@ public abstract class AbstractUpgradeCatalog implements 
UpgradeCatalog {
     return leafQueues;
   }
 
+  /**
+   *
+   * @param serviceName
+   * @param widgetMap
+   * @param sectionLayoutMap
+   * @throws AmbariException
+   */
+  protected void updateWidgetDefinitionsForService(String serviceName, 
Map<String, List<String>> widgetMap,
+                                                   Map<String, String> 
sectionLayoutMap) throws AmbariException {
+    AmbariManagementController ambariManagementController = 
injector.getInstance(AmbariManagementController.class);
+    AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
+    Type widgetLayoutType = new TypeToken<Map<String, 
List<WidgetLayout>>>(){}.getType();
+    Gson gson = injector.getInstance(Gson.class);
+    WidgetDAO widgetDAO = injector.getInstance(WidgetDAO.class);
+
+    Clusters clusters = ambariManagementController.getClusters();
+
+    Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters);
+    for (final Cluster cluster : clusterMap.values()) {
+      long clusterID = cluster.getClusterId();
+
+      StackId stackId = cluster.getDesiredStackVersion();
+      Map<String, Object> widgetDescriptor = null;
+      StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), 
stackId.getStackVersion());
+      ServiceInfo serviceInfo = stackInfo.getService(serviceName);
+      if (serviceInfo == null) {
+        LOG.info("Skipping updating widget definition, because " + serviceName 
+  " service is not present in cluster " +
+            "cluster_name= " + cluster.getClusterName());
+        continue;
+      }
+
+      for (String section : widgetMap.keySet()) {
+        List<String> widgets = widgetMap.get(section);
+        for (String widgetName : widgets) {
+          List<WidgetEntity> widgetEntities = widgetDAO.findByName(clusterID,
+              widgetName, "ambari", section);
+
+          if (widgetEntities != null && widgetEntities.size() > 0) {
+            WidgetEntity entityToUpdate = null;
+            if (widgetEntities.size() > 1) {
+              LOG.info("Found more that 1 entity with name = "+ widgetName +
+                  " for cluster = " + cluster.getClusterName() + ", skipping 
update.");
+            } else {
+              entityToUpdate = widgetEntities.iterator().next();
+            }
+            if (entityToUpdate != null) {
+              LOG.info("Updating widget: " + entityToUpdate.getWidgetName());
+              // Get the definition from widgets.json file
+              WidgetLayoutInfo targetWidgetLayoutInfo = null;
+              File widgetDescriptorFile = 
serviceInfo.getWidgetsDescriptorFile();
+              if (widgetDescriptorFile != null && 
widgetDescriptorFile.exists()) {
+                try {
+                  widgetDescriptor = gson.fromJson(new 
FileReader(widgetDescriptorFile), widgetLayoutType);
+                } catch (Exception ex) {
+                  String msg = "Error loading widgets from file: " + 
widgetDescriptorFile;
+                  LOG.error(msg, ex);
+                  widgetDescriptor = null;
+                }
+              }
+              if (widgetDescriptor != null) {
+                LOG.debug("Loaded widget descriptor: " + widgetDescriptor);
+                for (Object artifact : widgetDescriptor.values()) {
+                  List<WidgetLayout> widgetLayouts = (List<WidgetLayout>) 
artifact;
+                  for (WidgetLayout widgetLayout : widgetLayouts) {
+                    if 
(widgetLayout.getLayoutName().equals(sectionLayoutMap.get(section))) {
+                      for (WidgetLayoutInfo layoutInfo : 
widgetLayout.getWidgetLayoutInfoList()) {
+                        if (layoutInfo.getWidgetName().equals(widgetName)) {
+                          targetWidgetLayoutInfo = layoutInfo;
+                        }
+                      }
+                    }
+                  }
+                }
+              }
+              if (targetWidgetLayoutInfo != null) {
+                
entityToUpdate.setMetrics(gson.toJson(targetWidgetLayoutInfo.getMetricsInfo()));
+                
entityToUpdate.setWidgetValues(gson.toJson(targetWidgetLayoutInfo.getValues()));
+                
entityToUpdate.setDescription(targetWidgetLayoutInfo.getDescription());
+                widgetDAO.merge(entityToUpdate);
+              } else {
+                LOG.warn("Unable to find widget layout info for " + widgetName 
+
+                    " in the stack: " + stackId);
+              }
+            }
+          }
+        }
+      }
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
index aa557b1..b079843 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/SchemaUpgradeHelper.java
@@ -192,6 +192,7 @@ public class SchemaUpgradeHelper {
       catalogBinder.addBinding().to(UpgradeCatalog222.class);
       catalogBinder.addBinding().to(UpgradeCatalog230.class);
       catalogBinder.addBinding().to(UpgradeCatalog240.class);
+      catalogBinder.addBinding().to(UpgradeCatalog2402.class);
       catalogBinder.addBinding().to(UpgradeCatalog242.class);
       catalogBinder.addBinding().to(UpgradeCatalog250.class);
       catalogBinder.addBinding().to(FinalUpgradeCatalog.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index 7b675f1..ab3b493 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -572,7 +572,7 @@ public class UpgradeCatalog222 extends 
AbstractUpgradeCatalog {
     return Collections.emptyMap();
   }
 
-  private void updateWidgetDefinitionsForService(String serviceName, 
Map<String, List<String>> widgetMap,
+  protected void updateWidgetDefinitionsForService(String serviceName, 
Map<String, List<String>> widgetMap,
                                                  Map<String, String> 
sectionLayoutMap) throws AmbariException {
     AmbariManagementController ambariManagementController = 
injector.getInstance(AmbariManagementController.class);
     AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index 48de9ec..dab20a0 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -2660,89 +2660,6 @@ public class UpgradeCatalog240 extends 
AbstractUpgradeCatalog {
     updateWidgetDefinitionsForService("HDFS", widgetMap, sectionLayoutMap);
   }
 
-  private void updateWidgetDefinitionsForService(String serviceName, 
Map<String, List<String>> widgetMap,
-                                                 Map<String, String> 
sectionLayoutMap) throws AmbariException {
-    AmbariManagementController ambariManagementController = 
injector.getInstance(AmbariManagementController.class);
-    AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
-    Type widgetLayoutType = new TypeToken<Map<String, 
List<WidgetLayout>>>(){}.getType();
-    Gson gson = injector.getInstance(Gson.class);
-    WidgetDAO widgetDAO = injector.getInstance(WidgetDAO.class);
-
-    Clusters clusters = ambariManagementController.getClusters();
-
-    Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters);
-    for (final Cluster cluster : clusterMap.values()) {
-      long clusterID = cluster.getClusterId();
-
-      StackId stackId = cluster.getDesiredStackVersion();
-      Map<String, Object> widgetDescriptor = null;
-      StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), 
stackId.getStackVersion());
-      ServiceInfo serviceInfo = stackInfo.getService(serviceName);
-      if (serviceInfo == null) {
-        LOG.info("Skipping updating widget definition, because " + serviceName 
+  " service is not present in cluster " +
-          "cluster_name= " + cluster.getClusterName());
-        continue;
-      }
-
-      for (String section : widgetMap.keySet()) {
-        List<String> widgets = widgetMap.get(section);
-        for (String widgetName : widgets) {
-          List<WidgetEntity> widgetEntities = widgetDAO.findByName(clusterID,
-            widgetName, "ambari", section);
-
-          if (widgetEntities != null && widgetEntities.size() > 0) {
-            WidgetEntity entityToUpdate = null;
-            if (widgetEntities.size() > 1) {
-              LOG.info("Found more that 1 entity with name = "+ widgetName +
-                " for cluster = " + cluster.getClusterName() + ", skipping 
update.");
-            } else {
-              entityToUpdate = widgetEntities.iterator().next();
-            }
-            if (entityToUpdate != null) {
-              LOG.info("Updating widget: " + entityToUpdate.getWidgetName());
-              // Get the definition from widgets.json file
-              WidgetLayoutInfo targetWidgetLayoutInfo = null;
-              File widgetDescriptorFile = 
serviceInfo.getWidgetsDescriptorFile();
-              if (widgetDescriptorFile != null && 
widgetDescriptorFile.exists()) {
-                try {
-                  widgetDescriptor = gson.fromJson(new 
FileReader(widgetDescriptorFile), widgetLayoutType);
-                } catch (Exception ex) {
-                  String msg = "Error loading widgets from file: " + 
widgetDescriptorFile;
-                  LOG.error(msg, ex);
-                  widgetDescriptor = null;
-                }
-              }
-              if (widgetDescriptor != null) {
-                LOG.debug("Loaded widget descriptor: " + widgetDescriptor);
-                for (Object artifact : widgetDescriptor.values()) {
-                  List<WidgetLayout> widgetLayouts = (List<WidgetLayout>) 
artifact;
-                  for (WidgetLayout widgetLayout : widgetLayouts) {
-                    if 
(widgetLayout.getLayoutName().equals(sectionLayoutMap.get(section))) {
-                      for (WidgetLayoutInfo layoutInfo : 
widgetLayout.getWidgetLayoutInfoList()) {
-                        if (layoutInfo.getWidgetName().equals(widgetName)) {
-                          targetWidgetLayoutInfo = layoutInfo;
-                        }
-                      }
-                    }
-                  }
-                }
-              }
-              if (targetWidgetLayoutInfo != null) {
-                
entityToUpdate.setMetrics(gson.toJson(targetWidgetLayoutInfo.getMetricsInfo()));
-                
entityToUpdate.setWidgetValues(gson.toJson(targetWidgetLayoutInfo.getValues()));
-                
entityToUpdate.setDescription(targetWidgetLayoutInfo.getDescription());
-                widgetDAO.merge(entityToUpdate);
-              } else {
-                LOG.warn("Unable to find widget layout info for " + widgetName 
+
-                  " in the stack: " + stackId);
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-
   /**
    * @return True if the stack is >=HDP-2.5, false otherwise.
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog2402.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog2402.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog2402.java
new file mode 100644
index 0000000..4e54888
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog2402.java
@@ -0,0 +1,207 @@
+/*
+ * 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.ambari.server.upgrade;
+
+import com.google.common.collect.Lists;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.persist.Transactional;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.agent.RecoveryConfigHelper;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
+import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
+import org.apache.ambari.server.orm.dao.ArtifactDAO;
+import org.apache.ambari.server.orm.dao.ClusterDAO;
+import org.apache.ambari.server.orm.dao.PermissionDAO;
+import org.apache.ambari.server.orm.dao.PrincipalDAO;
+import org.apache.ambari.server.orm.dao.PrincipalTypeDAO;
+import org.apache.ambari.server.orm.dao.PrivilegeDAO;
+import org.apache.ambari.server.orm.dao.RemoteAmbariClusterDAO;
+import org.apache.ambari.server.orm.dao.RequestScheduleDAO;
+import org.apache.ambari.server.orm.dao.ResourceTypeDAO;
+import org.apache.ambari.server.orm.dao.RoleAuthorizationDAO;
+import org.apache.ambari.server.orm.dao.UserDAO;
+import org.apache.ambari.server.orm.dao.ViewInstanceDAO;
+import org.apache.ambari.server.orm.dao.WidgetDAO;
+import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
+import org.apache.ambari.server.orm.entities.ArtifactEntity;
+import org.apache.ambari.server.orm.entities.ClusterEntity;
+import org.apache.ambari.server.orm.entities.PermissionEntity;
+import org.apache.ambari.server.orm.entities.PrincipalEntity;
+import org.apache.ambari.server.orm.entities.PrincipalTypeEntity;
+import org.apache.ambari.server.orm.entities.PrivilegeEntity;
+import org.apache.ambari.server.orm.entities.RemoteAmbariClusterEntity;
+import org.apache.ambari.server.orm.entities.RequestScheduleEntity;
+import org.apache.ambari.server.orm.entities.ResourceEntity;
+import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
+import org.apache.ambari.server.orm.entities.RoleAuthorizationEntity;
+import org.apache.ambari.server.orm.entities.UserEntity;
+import org.apache.ambari.server.orm.entities.ViewEntityEntity;
+import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
+import org.apache.ambari.server.orm.entities.WidgetEntity;
+import org.apache.ambari.server.security.authorization.ResourceType;
+import org.apache.ambari.server.security.authorization.User;
+import org.apache.ambari.server.security.authorization.Users;
+import org.apache.ambari.server.state.AlertFirmness;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.RepositoryType;
+import org.apache.ambari.server.state.SecurityType;
+import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.StackInfo;
+import org.apache.ambari.server.state.State;
+import org.apache.ambari.server.state.kerberos.KerberosComponentDescriptor;
+import org.apache.ambari.server.state.kerberos.KerberosDescriptor;
+import org.apache.ambari.server.state.kerberos.KerberosDescriptorFactory;
+import org.apache.ambari.server.state.kerberos.KerberosIdentityDescriptor;
+import org.apache.ambari.server.state.kerberos.KerberosKeytabDescriptor;
+import org.apache.ambari.server.state.kerberos.KerberosPrincipalDescriptor;
+import org.apache.ambari.server.state.kerberos.KerberosServiceDescriptor;
+import org.apache.ambari.server.state.stack.WidgetLayout;
+import org.apache.ambari.server.state.stack.WidgetLayoutInfo;
+import org.apache.ambari.server.view.DefaultMasker;
+import org.apache.ambari.view.ClusterType;
+import org.apache.ambari.view.MaskException;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.support.JdbcUtils;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import javax.persistence.TypedQuery;
+import java.io.File;
+import java.io.FileReader;
+import java.lang.reflect.Type;
+import java.sql.Clob;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Upgrade catalog for version 2.4.0.
+ */
+public class UpgradeCatalog2402 extends AbstractUpgradeCatalog {
+
+  @Inject
+  ClusterDAO clusterDAO;
+
+  @Inject
+  Configuration config;
+
+  /**
+   * Logger.
+   */
+  private static final Logger LOG = 
LoggerFactory.getLogger(UpgradeCatalog2402.class);
+
+  // ----- Constructors ------------------------------------------------------
+
+  /**
+   * Don't forget to register new UpgradeCatalogs in {@link 
SchemaUpgradeHelper.UpgradeHelperModule#configure()}
+   *
+   * @param injector Guice injector to track dependencies and uses bindings to 
inject them.
+   */
+  @Inject
+  public UpgradeCatalog2402(Injector injector) {
+    super(injector);
+    injector.injectMembers(this);
+  }
+
+  // ----- UpgradeCatalog ----------------------------------------------------
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getTargetVersion() {
+    return "2.4.0.2";
+  }
+
+  // ----- AbstractUpgradeCatalog --------------------------------------------
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSourceVersion() {
+    return "2.4.0";
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  protected void executeDDLUpdates() throws AmbariException, SQLException {
+
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  protected void executePreDMLUpdates() throws AmbariException, SQLException {
+
+  }
+
+  @Override
+  protected void executeDMLUpdates() throws AmbariException, SQLException {
+    updateKafkaWidgetDefinition();
+  }
+
+
+  protected void updateKafkaWidgetDefinition() throws AmbariException {
+    LOG.info("Updating Kafka widget definition.");
+
+    Map<String, List<String>> widgetMap = new HashMap<>();
+    Map<String, String> sectionLayoutMap = new HashMap<>();
+
+    List<String> kafkaSummaryWidgets = new ArrayList<>(Arrays.asList("Active 
Controller Count"));
+    widgetMap.put("KAFKA_SUMMARY", kafkaSummaryWidgets);
+    sectionLayoutMap.put("KAFKA_SUMMARY", "default_kafka_dashboard");
+
+    updateWidgetDefinitionsForService("KAFKA", widgetMap, sectionLayoutMap);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
index 980b651..31093f1 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog242.java
@@ -102,7 +102,7 @@ public class UpgradeCatalog242 extends 
AbstractUpgradeCatalog {
    */
   @Override
   public String getSourceVersion() {
-    return "2.4.0";
+    return "2.4.0.2";
   }
 
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
index ecdd4f3..b86fad9 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog250.java
@@ -97,7 +97,7 @@ public class UpgradeCatalog250 extends AbstractUpgradeCatalog 
{
    */
   @Override
   public String getSourceVersion() {
-    return "2.4.0";
+    return "2.4.2";
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/e4f66cd9/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
index 1ea42b2..3d0979a 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog250Test.java
@@ -95,7 +95,6 @@ public class UpgradeCatalog250Test {
     reset(entityManagerProvider);
     expect(entityManagerProvider.get()).andReturn(entityManager).anyTimes();
     replay(entityManagerProvider);
-
   }
 
   @After

Reply via email to