ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-9762. Could not start services (Knox etc...) after Ambari only upgrade from 1.7.0 to 2.0.0.(vbrodetskyi)
Date Tue, 24 Feb 2015 10:43:05 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 d6a67cfb9 -> 13fe4720c


AMBARI-9762. Could not start services (Knox etc...) after Ambari only upgrade from 1.7.0 to
2.0.0.(vbrodetskyi)


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

Branch: refs/heads/branch-2.0.0
Commit: 13fe4720c39d7a4dadcf19381b47d17ae673cc10
Parents: d6a67cf
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Tue Feb 24 12:20:47 2015 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Tue Feb 24 12:20:47 2015 +0200

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog200.java       | 16 +++++--
 .../server/upgrade/UpgradeCatalog200Test.java   | 45 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/13fe4720/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
index 8d8f6c4..3a3e3bb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog200.java
@@ -36,6 +36,7 @@ import org.apache.ambari.server.orm.dao.ClusterDAO;
 import org.apache.ambari.server.orm.dao.ClusterServiceDAO;
 import org.apache.ambari.server.orm.dao.HostComponentDesiredStateDAO;
 import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
+import org.apache.ambari.server.orm.dao.MetainfoDAO;
 import org.apache.ambari.server.orm.dao.ServiceComponentDesiredStateDAO;
 import org.apache.ambari.server.orm.dao.ServiceDesiredStateDAO;
 import org.apache.ambari.server.orm.entities.ClusterEntity;
@@ -331,10 +332,17 @@ public class UpgradeCatalog200 extends AbstractUpgradeCatalog {
       String stackRepoId = stackName + "-" + stackVersion;
 
       for (OperatingSystemInfo osi : ambariMetaInfo.getOperatingSystems(stackName, stackVersion))
{
-        RepositoryInfo repositoryInfo = ambariMetaInfo.getRepository(stackName, stackVersion,
osi.getOsType(), stackRepoId);
-        String baseUrl = repositoryInfo.getBaseUrl();
-        ambariMetaInfo.updateRepoBaseURL(stackName, stackVersion, osi.getOsType(),
-                stackRepoId, baseUrl);
+        MetainfoDAO metaInfoDAO = injector.getInstance(MetainfoDAO.class);
+        String repoMetaKey = AmbariMetaInfo.generateRepoMetaKey(stackName,stackVersion,osi.getOsType(),
+                stackRepoId,AmbariMetaInfo.REPOSITORY_XML_PROPERTY_BASEURL);
+        // Check if default repo is used and not persisted
+        if (metaInfoDAO.findByKey(repoMetaKey) == null) {
+          RepositoryInfo repositoryInfo = ambariMetaInfo.getRepository(stackName, stackVersion,
osi.getOsType(), stackRepoId);
+          // We save default base url which has not changed during upgrade as base url
+          String baseUrl = repositoryInfo.getDefaultBaseUrl();
+          ambariMetaInfo.updateRepoBaseURL(stackName, stackVersion, osi.getOsType(),
+                  stackRepoId, baseUrl);
+        }
       }
     }
    

http://git-wip-us.apache.org/repos/asf/ambari/blob/13fe4720/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
index 03df4d7..6db805f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog200Test.java
@@ -43,10 +43,12 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.HashSet;
 
 import javax.persistence.EntityManager;
 
 import com.google.inject.AbstractModule;
+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;
@@ -70,9 +72,12 @@ 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.OperatingSystemInfo;
 import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.RepositoryInfo;
 import org.apache.ambari.server.state.SecurityState;
 import org.apache.ambari.server.state.SecurityType;
+import org.apache.ambari.server.state.StackId;
 import org.easymock.Capture;
 import org.easymock.EasyMockSupport;
 import org.junit.After;
@@ -385,6 +390,46 @@ public class UpgradeCatalog200Test {
   }
 
   @Test
+  public void testPersistHDPRepo() throws Exception {
+    EasyMockSupport easyMockSupport = new EasyMockSupport();
+    final AmbariManagementController  mockAmbariManagementController = easyMockSupport.createStrictMock(AmbariManagementController.class);
+    final AmbariMetaInfo mockAmbariMetaInfo = easyMockSupport.createStrictMock(AmbariMetaInfo.class);
+    final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+    final Cluster mockCluster = easyMockSupport.createStrictMock(Cluster.class);
+    final Map<String, Cluster> clusterMap = new HashMap<String, Cluster>();
+    clusterMap.put("c1",mockCluster);
+    OperatingSystemInfo osi = new OperatingSystemInfo("redhat6");
+    HashSet<OperatingSystemInfo> osiSet = new HashSet<OperatingSystemInfo>();
+    osiSet.add(osi);
+    StackId stackId = new StackId("HDP","2.2");
+    RepositoryInfo mockRepositoryInfo = easyMockSupport.createStrictMock(RepositoryInfo.class);
+
+    final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+      @Override
+      protected void configure() {
+        bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+        bind(Clusters.class).toInstance(mockClusters);
+        bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+        bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
+      }
+    });
+
+    expect(mockAmbariManagementController.getAmbariMetaInfo()).andReturn(mockAmbariMetaInfo);
+    expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+    expect(mockClusters.getClusters()).andReturn(clusterMap).once();
+    expect(mockCluster.getCurrentStackVersion()).andReturn(stackId).once();
+    expect(mockAmbariMetaInfo.getOperatingSystems("HDP", "2.2")).andReturn(osiSet).once();
+    expect(mockAmbariMetaInfo.getRepository("HDP", "2.2", "redhat6", "HDP-2.2")).andReturn(mockRepositoryInfo).once();
+    expect(mockRepositoryInfo.getDefaultBaseUrl()).andReturn("http://baseurl").once();
+    mockAmbariMetaInfo.updateRepoBaseURL("HDP", "2.2", "redhat6", "HDP-2.2", "http://baseurl");
+    expectLastCall().once();
+
+    easyMockSupport.replayAll();
+    mockInjector.getInstance(UpgradeCatalog200.class).persistHDPRepo();
+    easyMockSupport.verifyAll();
+  }
+
+  @Test
   public void testUpdateClusterEnvConfiguration() throws Exception {
     EasyMockSupport easyMockSupport = new EasyMockSupport();
     final AmbariManagementController  mockAmbariManagementController = easyMockSupport.createStrictMock(AmbariManagementController.class);


Mime
View raw message