ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject git commit: AMBARI-7779. Broken Dashboard page after upgrade to ambari-1.7.0 version. (jaimin)
Date Wed, 15 Oct 2014 16:45:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 6d6189161 -> 7fad17999


AMBARI-7779. Broken Dashboard page after upgrade to ambari-1.7.0 version. (jaimin)


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

Branch: refs/heads/branch-1.7.0
Commit: 7fad179996d562390ab00547f0ed55d1da4cee45
Parents: 6d61891
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Wed Oct 15 09:45:34 2014 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Wed Oct 15 09:45:34 2014 -0700

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog170.java       |  25 +++-
 .../server/upgrade/UpgradeCatalog170Test.java   | 115 +++++++++++--------
 2 files changed, 88 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7fad1799/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
index c874a79..c7a2e4d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
@@ -43,10 +43,10 @@ import org.apache.ambari.server.orm.dao.UserDAO;
 import org.apache.ambari.server.orm.dao.ViewDAO;
 import org.apache.ambari.server.orm.dao.ViewInstanceDAO;
 import org.apache.ambari.server.orm.entities.ClusterConfigEntity;
+import org.apache.ambari.server.orm.entities.ClusterConfigMappingEntity;
 import org.apache.ambari.server.orm.entities.ClusterEntity;
 import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
 import org.apache.ambari.server.orm.entities.ClusterServiceEntityPK;
-import org.apache.ambari.server.orm.entities.ClusterConfigMappingEntity;
 import org.apache.ambari.server.orm.entities.ConfigGroupConfigMappingEntity;
 import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
 import org.apache.ambari.server.orm.entities.HostComponentStateEntity;
@@ -70,6 +70,7 @@ 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.State;
 import org.apache.ambari.server.utils.StageUtils;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.slf4j.Logger;
@@ -646,6 +647,28 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
     addJobsViewPermissions();
     moveConfigGroupsGlobalToEnv();
     addMissingConfigs();
+    updateClusterProvisionState();
+  }
+
+  public void updateClusterProvisionState() {
+    // Change the provisioning_state of the cluster to INIT state
+    executeInTransaction(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          final ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
+          EntityManager em = getEntityManagerProvider().get();
+          List<ClusterEntity> clusterEntities = clusterDAO.findAll();
+          for (ClusterEntity clusterEntity : clusterEntities) {
+            clusterEntity.setProvisioningState(State.INSTALLED);
+            em.merge(clusterEntity);
+          }
+        } catch (Exception e) {
+          LOG.warn("Updating cluster provisioning_state to INSTALLED threw " +
+              "exception. ", e);
+        }
+      }
+    });
   }
 
   public void moveHcatalogIntoHiveService() throws AmbariException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7fad1799/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index 57ddd40..3271864 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -18,13 +18,6 @@
 
 package org.apache.ambari.server.upgrade;
 
-import static org.apache.ambari.server.upgrade.UpgradeCatalog170.CLUSTER_STATE_STACK_HDP_2_1;
-import static org.apache.ambari.server.upgrade.UpgradeCatalog170.JOBS_VIEW_NAME;
-import static org.apache.ambari.server.upgrade.UpgradeCatalog170.SHOW_JOBS_FOR_NON_ADMIN_KEY;
-import static org.apache.ambari.server.upgrade.UpgradeCatalog170.YARN_RESOURCEMANAGER_WEBAPP_ADDRESS_PROPERTY;
-import static org.apache.ambari.server.upgrade.UpgradeCatalog170.YARN_SITE;
-import static org.apache.ambari.server.upgrade.UpgradeCatalog170.YARN_TIMELINE_SERVICE_WEBAPP_ADDRESS_PROPERTY;
-
 import com.google.inject.Binder;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
@@ -85,6 +78,7 @@ import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.HostComponentAdminState;
 import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.easymock.Capture;
 import org.easymock.IAnswer;
@@ -122,6 +116,12 @@ import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
 import static junit.framework.Assert.assertTrue;
+import static org.apache.ambari.server.upgrade.UpgradeCatalog170.CLUSTER_STATE_STACK_HDP_2_1;
+import static org.apache.ambari.server.upgrade.UpgradeCatalog170.JOBS_VIEW_NAME;
+import static org.apache.ambari.server.upgrade.UpgradeCatalog170.SHOW_JOBS_FOR_NON_ADMIN_KEY;
+import static org.apache.ambari.server.upgrade.UpgradeCatalog170.YARN_RESOURCEMANAGER_WEBAPP_ADDRESS_PROPERTY;
+import static org.apache.ambari.server.upgrade.UpgradeCatalog170.YARN_SITE;
+import static org.apache.ambari.server.upgrade.UpgradeCatalog170.YARN_TIMELINE_SERVICE_WEBAPP_ADDRESS_PROPERTY;
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.capture;
 import static org.easymock.EasyMock.createMockBuilder;
@@ -148,7 +148,7 @@ public class UpgradeCatalog170Test {
   private final String DESIRED_STACK_VERSION = "{\"stackName\":\"HDP\",\"stackVersion\":\"2.0.6\"}";
 
   Provider<EntityManager> entityManagerProvider = createStrictMock(Provider.class);
-  EntityManager entityManager = createStrictMock(EntityManager.class);
+  EntityManager entityManager = createNiceMock(EntityManager.class);
 
   @Before
   public void init() {
@@ -183,6 +183,7 @@ public class UpgradeCatalog170Test {
     clusterEntity.setClusterId(1L);
     clusterEntity.setClusterName(CLUSTER_NAME);
     clusterEntity.setDesiredStackVersion(DESIRED_STACK_VERSION);
+    clusterEntity.setProvisioningState(State.INIT);
     clusterEntity.setResource(resourceEntity);
     clusterDAO.create(clusterEntity);
     return clusterEntity;
@@ -278,49 +279,6 @@ public class UpgradeCatalog170Test {
   }
 
   @Test
-  public void testMoveHcatalogIntoHiveService()  throws AmbariException{
-    final ClusterEntity clusterEntity = createCluster();
-    final ClusterServiceEntity clusterServiceEntityHDFS = addService(clusterEntity, "HDFS");
-    final ClusterServiceEntity clusterServiceEntityHIVE = addService(clusterEntity, "HIVE");
-    final ClusterServiceEntity clusterServiceEntityHCATALOG = addService(clusterEntity, "HCATALOG");
-    final ClusterServiceEntity clusterServiceEntityWEBHCAT = addService(clusterEntity, "WEBHCAT");
-    final HostEntity hostEntity = createHost(clusterEntity);
-    addComponent(clusterEntity, clusterServiceEntityHDFS, hostEntity, "NAMENODE");
-    addComponent(clusterEntity, clusterServiceEntityHIVE, hostEntity, "HIVE_SERVER");
-    addComponent(clusterEntity, clusterServiceEntityHCATALOG, hostEntity, "HCAT");
-    addComponent(clusterEntity, clusterServiceEntityWEBHCAT, hostEntity, "WEBHCAT_SERVER");
-    UpgradeCatalog170 upgradeCatalog170 = injector.getInstance(UpgradeCatalog170.class);
-    upgradeCatalog170.moveHcatalogIntoHiveService();
-
-    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
-    ServiceComponentDesiredStateEntityPK pkHCATInHive = new ServiceComponentDesiredStateEntityPK();
-    pkHCATInHive.setComponentName("HCAT");
-    pkHCATInHive.setClusterId(clusterEntity.getClusterId());
-    pkHCATInHive.setServiceName("HIVE");
-    ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO.findByPK(pkHCATInHive);
-    assertNotNull(serviceComponentDesiredStateEntity);
-
-    HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector.getInstance(HostComponentDesiredStateDAO.class);
-    HostComponentDesiredStateEntityPK hcDesiredStateEntityPk  = new HostComponentDesiredStateEntityPK();
-    hcDesiredStateEntityPk.setServiceName("HIVE");
-    hcDesiredStateEntityPk.setClusterId(clusterEntity.getClusterId());
-    hcDesiredStateEntityPk.setComponentName("HCAT");
-    hcDesiredStateEntityPk.setHostName(HOST_NAME);
-    HostComponentDesiredStateEntity hcDesiredStateEntity = hostComponentDesiredStateDAO.findByPK(hcDesiredStateEntityPk);
-    assertNotNull(hcDesiredStateEntity);
-
-    HostComponentStateDAO hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
-    HostComponentStateEntityPK hcStateEntityPk  = new HostComponentStateEntityPK();
-    hcStateEntityPk.setServiceName("HIVE");
-    hcStateEntityPk.setClusterId(clusterEntity.getClusterId());
-    hcStateEntityPk.setComponentName("HCAT");
-    hcStateEntityPk.setHostName(HOST_NAME);
-    HostComponentStateEntity hcStateEntity = hostComponentStateDAO.findByPK(hcStateEntityPk);
-    assertNotNull(hcStateEntity);
-  }
-
-
-  @Test
   public void testExecuteDDLUpdates() throws Exception {
 
     final DBAccessor dbAccessor = createNiceMock(DBAccessor.class);
@@ -681,6 +639,61 @@ public class UpgradeCatalog170Test {
         viewRegistry, clusterEntity, configEntity, configMappingEntity, clusterStateEntity);
   }
 
+  @Test
+  public void testMoveHcatalogIntoHiveService()  throws AmbariException {
+    final ClusterEntity clusterEntity = createCluster();
+    final ClusterServiceEntity clusterServiceEntityHDFS = addService(clusterEntity, "HDFS");
+    final ClusterServiceEntity clusterServiceEntityHIVE = addService(clusterEntity, "HIVE");
+    final ClusterServiceEntity clusterServiceEntityHCATALOG = addService(clusterEntity, "HCATALOG");
+    final ClusterServiceEntity clusterServiceEntityWEBHCAT = addService(clusterEntity, "WEBHCAT");
+    final HostEntity hostEntity = createHost(clusterEntity);
+    addComponent(clusterEntity, clusterServiceEntityHDFS, hostEntity, "NAMENODE");
+    addComponent(clusterEntity, clusterServiceEntityHIVE, hostEntity, "HIVE_SERVER");
+    addComponent(clusterEntity, clusterServiceEntityHCATALOG, hostEntity, "HCAT");
+    addComponent(clusterEntity, clusterServiceEntityWEBHCAT, hostEntity, "WEBHCAT_SERVER");
+    UpgradeCatalog170 upgradeCatalog170 = injector.getInstance(UpgradeCatalog170.class);
+    upgradeCatalog170.moveHcatalogIntoHiveService();
+
+    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
+    ServiceComponentDesiredStateEntityPK pkHCATInHive = new ServiceComponentDesiredStateEntityPK();
+    pkHCATInHive.setComponentName("HCAT");
+    pkHCATInHive.setClusterId(clusterEntity.getClusterId());
+    pkHCATInHive.setServiceName("HIVE");
+    ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO.findByPK(pkHCATInHive);
+    assertNotNull(serviceComponentDesiredStateEntity);
+
+    HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector.getInstance(HostComponentDesiredStateDAO.class);
+    HostComponentDesiredStateEntityPK hcDesiredStateEntityPk  = new HostComponentDesiredStateEntityPK();
+    hcDesiredStateEntityPk.setServiceName("HIVE");
+    hcDesiredStateEntityPk.setClusterId(clusterEntity.getClusterId());
+    hcDesiredStateEntityPk.setComponentName("HCAT");
+    hcDesiredStateEntityPk.setHostName(HOST_NAME);
+    HostComponentDesiredStateEntity hcDesiredStateEntity = hostComponentDesiredStateDAO.findByPK(hcDesiredStateEntityPk);
+    assertNotNull(hcDesiredStateEntity);
+
+    HostComponentStateDAO hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
+    HostComponentStateEntityPK hcStateEntityPk  = new HostComponentStateEntityPK();
+    hcStateEntityPk.setServiceName("HIVE");
+    hcStateEntityPk.setClusterId(clusterEntity.getClusterId());
+    hcStateEntityPk.setComponentName("HCAT");
+    hcStateEntityPk.setHostName(HOST_NAME);
+    HostComponentStateEntity hcStateEntity = hostComponentStateDAO.findByPK(hcStateEntityPk);
+    assertNotNull(hcStateEntity);
+  }
+
+  @Test
+  public void updateClusterProvisionState()  throws AmbariException {
+    ClusterEntity clusterEntity = createCluster();
+    UpgradeCatalog170 upgradeCatalog170 = injector.getInstance(UpgradeCatalog170.class);
+    upgradeCatalog170.updateClusterProvisionState();    //action
+
+    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
+    String assertMsg = "updated provisioning state should be installed";
+    String expectedState = "INSTALLED";
+    String actualState = clusterDAO.findById(1L).getProvisioningState().name();
+    assertEquals(assertMsg,expectedState, actualState);  //validation
+  }
+
 
   @Test
   public void testGetTargetVersion() throws Exception {


Mime
View raw message