ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject git commit: AMBARI-7353. Upgrade from ambari 1.6.0 -> 1.7.0 fails, with "schema upgrade failed". (jaimin)
Date Thu, 18 Sep 2014 18:21:34 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 3bbbb5ec8 -> 742b71893


AMBARI-7353. Upgrade from ambari 1.6.0 -> 1.7.0 fails, with "schema upgrade failed". (jaimin)


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

Branch: refs/heads/trunk
Commit: 742b71893633afd7ce1424239bd8937ba502a7a5
Parents: 3bbbb5e
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Thu Sep 18 11:21:27 2014 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Thu Sep 18 11:21:27 2014 -0700

----------------------------------------------------------------------
 .../server/api/util/StackExtensionHelper.java   | 119 ++++++++++---------
 .../server/upgrade/UpgradeCatalog170.java       |  43 +++----
 2 files changed, 88 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/742b7189/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
index 3e211fe..2c5396b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
@@ -17,6 +17,40 @@
  */
 package org.apache.ambari.server.api.util;
 
+import com.google.inject.Injector;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.metadata.ActionMetadata;
+import org.apache.ambari.server.state.ClientConfigFileDefinition;
+import org.apache.ambari.server.state.CommandScriptDefinition;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.CustomCommandDefinition;
+import org.apache.ambari.server.state.DependencyInfo;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.ServiceOsSpecific;
+import org.apache.ambari.server.state.StackInfo;
+import org.apache.ambari.server.state.stack.ConfigurationXml;
+import org.apache.ambari.server.state.stack.RepositoryXml;
+import org.apache.ambari.server.state.stack.ServiceMetainfoXml;
+import org.apache.ambari.server.state.stack.StackMetainfoXml;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -31,33 +65,6 @@ import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
 
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.metadata.ActionMetadata;
-import org.apache.ambari.server.state.*;
-import org.apache.ambari.server.state.stack.ConfigurationXml;
-import org.apache.ambari.server.state.stack.RepositoryXml;
-import org.apache.ambari.server.state.stack.ServiceMetainfoXml;
-import org.apache.ambari.server.state.stack.StackMetainfoXml;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import com.google.inject.Injector;
-
 /**
  * Helper methods for providing stack extension behavior -
  * Apache Jira: AMBARI-2819
@@ -520,8 +527,8 @@ public class StackExtensionHelper {
   }
 
   void populateServicesForStack(StackInfo stackInfo) throws
-          ParserConfigurationException, SAXException,
-          XPathExpressionException, IOException, JAXBException {
+      ParserConfigurationException, SAXException,
+      XPathExpressionException, IOException, JAXBException {
     List<ServiceInfo> services = new ArrayList<ServiceInfo>();
     File servicesFolder = new File(stackRoot.getAbsolutePath() + File
       .separator + stackInfo.getName() + File.separator + stackInfo.getVersion()
@@ -554,29 +561,33 @@ public class StackExtensionHelper {
 
           //Reading v2 service metainfo (may contain multiple services)
           // Get services from metadata
-          ServiceMetainfoXml smiv2x =
-                  unmarshal(ServiceMetainfoXml.class, metainfoFile);
-          List<ServiceInfo> serviceInfos = smiv2x.getServices();
-          for (ServiceInfo serviceInfo : serviceInfos) {
-            serviceInfo.setSchemaVersion(AmbariMetaInfo.SCHEMA_VERSION_2);
-
-            // Find service package folder
-            String servicePackageDir = resolveServicePackageFolder(
-                    stackRoot.getAbsolutePath(), stackInfo,
-                    serviceFolder.getName(), serviceInfo.getName());
-            serviceInfo.setServicePackageFolder(servicePackageDir);
-
-            // process metrics.json
-            if (metricsJson.exists())
-              serviceInfo.setMetricsFile(metricsJson);
-            if (alertsJson.exists())
-              serviceInfo.setAlertsFile(alertsJson);
-
-            // Get all properties from all "configs/*-site.xml" files
-            setPropertiesFromConfigs(serviceFolder, serviceInfo);
-
-            // Add now to be removed while iterating extension graph
-            services.add(serviceInfo);
+          try {
+            ServiceMetainfoXml smiv2x =
+                unmarshal(ServiceMetainfoXml.class, metainfoFile);
+            List<ServiceInfo> serviceInfos = smiv2x.getServices();
+            for (ServiceInfo serviceInfo : serviceInfos) {
+              serviceInfo.setSchemaVersion(AmbariMetaInfo.SCHEMA_VERSION_2);
+
+              // Find service package folder
+              String servicePackageDir = resolveServicePackageFolder(
+                  stackRoot.getAbsolutePath(), stackInfo,
+                  serviceFolder.getName(), serviceInfo.getName());
+              serviceInfo.setServicePackageFolder(servicePackageDir);
+
+              // process metrics.json
+              if (metricsJson.exists())
+                serviceInfo.setMetricsFile(metricsJson);
+              if (alertsJson.exists())
+                serviceInfo.setAlertsFile(alertsJson);
+
+              // Get all properties from all "configs/*-site.xml" files
+              setPropertiesFromConfigs(serviceFolder, serviceInfo);
+
+              // Add now to be removed while iterating extension graph
+              services.add(serviceInfo);
+            }
+          } catch (JAXBException e) {
+            LOG.warn("Error while parsing metainfo.xml for a service: " + serviceFolder.getAbsolutePath(),
e);
           }
         }
       } catch (Exception e) {
@@ -609,13 +620,13 @@ public class StackExtensionHelper {
       servicePackageFolder = expectedSubPath;
       String message = String.format(
               "Service package folder for service %s" +
-                      "for stack %s has been resolved to %s",
+                      " for stack %s has been resolved to %s",
               serviceName, stackId, servicePackageFolder);
       LOG.debug(message);
     } else {
         String message = String.format(
                 "Service package folder %s for service %s " +
-                        "for stack %s does not exist.",
+                        " for stack %s does not exist.",
                 packageDir.getAbsolutePath(), serviceName, stackId);
         LOG.debug(message);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/742b7189/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 7eb1116..a3198c1 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
@@ -560,14 +560,25 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
 
   @Override
   protected void executeDMLUpdates() throws AmbariException, SQLException {
-    // Update historic records with the log paths, but only enough so as to not prolong the
upgrade process
-    moveHcatalogIntoHiveService();
-    moveWebHcatIntoHiveService();
 
     executeInTransaction(new Runnable() {
       @Override
       public void run() {
         try {
+          moveHcatalogIntoHiveService();
+          moveWebHcatIntoHiveService();
+        } catch (Exception e) {
+          LOG.warn("Integrating HCatalog and WebHCat services into Hive threw " +
+              "exception. ", e);
+        }
+      }
+    });
+
+    // Update historic records with the log paths, but only enough so as to not prolong the
upgrade process
+    executeInTransaction(new Runnable() {
+      @Override
+      public void run() {
+        try {
           HostRoleCommandDAO hostRoleCommandDAO = injector.getInstance(HostRoleCommandDAO.class);
           EntityManager em = getEntityManagerProvider().get();
           CriteriaBuilder cb = em.getCriteriaBuilder();
@@ -644,14 +655,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
   }
 
   private void moveComponentsIntoService(String serviceName, String serviceNameToBeDeleted,
String componentName) throws AmbariException {
-    /**
-     * 1. ADD servicecomponentdesiredstate: Add HCAT HIVE entry:
-     * 2. Update hostcomponentdesiredstate: service_name to HIVE where service_name is HCATALOG:
-     * 3. Update hostcomponentstate: service_name to HIVE where service_name is HCATALOG:
-     * 4. DELETE servicecomponentdesiredstate: where component_name is HCAT and service_name
is HCATALOG :
-     * 5. Delete servicedesiredstate where  service_name is HCATALOG:
-     * 6. Delete clusterservices where service_name is  HCATALOG:
-     */
+    EntityManager em = getEntityManagerProvider().get();
     ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
     ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
     ServiceDesiredStateDAO serviceDesiredStateDAO = injector.getInstance(ServiceDesiredStateDAO.class);
@@ -695,7 +699,6 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
       serviceComponentDesiredStateEntity.setDesiredStackVersion(serviceComponentDesiredStateEntityToDelete.getDesiredStackVersion());
       serviceComponentDesiredStateEntity.setDesiredState(serviceComponentDesiredStateEntityToDelete.getDesiredState());
       serviceComponentDesiredStateEntity.setClusterServiceEntity(clusterServiceEntity);
-      //serviceComponentDesiredStateDAO.create(serviceComponentDesiredStateEntity);
 
       Iterator<HostComponentDesiredStateEntity> hostComponentDesiredStateIterator =
serviceComponentDesiredStateEntityToDelete.getHostComponentDesiredStateEntities().iterator();
       Iterator<HostComponentStateEntity> hostComponentStateIterator = serviceComponentDesiredStateEntityToDelete.getHostComponentStateEntities().iterator();
@@ -714,8 +717,8 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
         hostComponentDesiredStateEntity.setRestartRequired(hcDesiredStateEntityToBeDeleted.isRestartRequired());
         hostComponentDesiredStateEntity.setServiceName(serviceName);
         hostComponentDesiredStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
-        hostComponentDesiredStateDAO.merge(hostComponentDesiredStateEntity);
-        hostComponentDesiredStateDAO.remove(hcDesiredStateEntityToBeDeleted);
+        em.merge(hostComponentDesiredStateEntity);
+        em.remove(hcDesiredStateEntityToBeDeleted);
       }
 
       while (hostComponentStateIterator.hasNext()) {
@@ -729,14 +732,14 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
         hostComponentStateEntity.setHostEntity(hcStateToBeDeleted.getHostEntity());
         hostComponentStateEntity.setServiceName(serviceName);
         hostComponentStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
-        hostComponentStateDAO.merge(hostComponentStateEntity);
-        hostComponentStateDAO.remove(hcStateToBeDeleted);
+        em.merge(hcStateToBeDeleted);
+        em.remove(hcStateToBeDeleted);
       }
       serviceComponentDesiredStateEntity.setClusterServiceEntity(clusterServiceEntity);
-      serviceComponentDesiredStateDAO.merge(serviceComponentDesiredStateEntity);
-      serviceComponentDesiredStateDAO.remove(serviceComponentDesiredStateEntityToDelete);
-      serviceDesiredStateDAO.remove(serviceDesiredStateEntity);
-      clusterServiceDAO.remove(clusterServiceEntityToBeDeleted);
+      em.merge(serviceComponentDesiredStateEntity);
+      em.remove(serviceComponentDesiredStateEntityToDelete);
+      em.remove(serviceDesiredStateEntity);
+      em.remove(clusterServiceEntityToBeDeleted);
     }
   }
 


Mime
View raw message