ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject ambari git commit: Revert "AMBARI-10432. RU Improvements. Part 1 (dlysnichenko)"
Date Fri, 10 Apr 2015 13:38:55 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk fc8552e54 -> ed3cd9533


Revert "AMBARI-10432. RU Improvements. Part 1 (dlysnichenko)"

This reverts commit 7a8a7f71f633e52e9f87a6d1ca87fc155fe105cb.


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

Branch: refs/heads/trunk
Commit: ed3cd953393f12d0b1114415ddf2dca2a7aa5621
Parents: fc8552e
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Fri Apr 10 16:26:58 2015 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Fri Apr 10 16:38:24 2015 +0300

----------------------------------------------------------------------
 .../internal/HostComponentResourceProvider.java | 16 ------
 .../upgrades/FinalizeUpgradeAction.java         | 56 --------------------
 .../src/main/resources/properties.json          |  1 -
 .../HostComponentResourceProviderTest.java      | 38 ++++++-------
 4 files changed, 15 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ed3cd953/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
index 4c37d5b..ab5c31c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostComponentResourceProvider.java
@@ -21,9 +21,6 @@ import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.assistedinject.Assisted;
 import com.google.inject.assistedinject.AssistedInject;
-import org.apache.ambari.server.orm.dao.HostVersionDAO;
-import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
-import org.apache.ambari.server.orm.entities.HostVersionEntity;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
 import org.apache.ambari.server.controller.AmbariManagementController;
@@ -48,7 +45,6 @@ import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentHost;
@@ -103,8 +99,6 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
       = PropertyHelper.getPropertyId("HostRoles", "desired_admin_state");
   protected static final String HOST_COMPONENT_MAINTENANCE_STATE_PROPERTY_ID
       = "HostRoles/maintenance_state";
-  protected static final String HOST_COMPONENT_HDP_VERSION
-      = PropertyHelper.getPropertyId("HostRoles", "hdp_version");
 
   //Component name mappings
   private final Map<String, PropertyProvider> HOST_COMPONENT_PROPERTIES_PROVIDER =
new HashMap<String, PropertyProvider>();
@@ -127,9 +121,6 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
   @Inject
   private MaintenanceStateHelper maintenanceStateHelper;
 
-  @Inject
-  private HostVersionDAO hostVersionDAO;
-
   // ----- Constructors ----------------------------------------------------
 
   /**
@@ -251,13 +242,6 @@ public class HostComponentResourceProvider extends AbstractControllerResourcePro
       setResourceProperty(resource, HOST_COMPONENT_STALE_CONFIGS_PROPERTY_ID,
               response.isStaleConfig(), requestedIds);
 
-      HostVersionEntity versionEntity = hostVersionDAO.
-              findByHostAndStateCurrent(response.getClusterName(), response.getHostname());
-      if (versionEntity != null) {
-        setResourceProperty(resource, HOST_COMPONENT_HDP_VERSION,
-                versionEntity.getRepositoryVersion().getDisplayName(), requestedIds);
-      }
-
       if (response.getAdminState() != null) {
         setResourceProperty(resource, HOST_COMPONENT_DESIRED_ADMIN_STATE_PROPERTY_ID,
                 response.getAdminState(), requestedIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed3cd953/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
index fc9774b..01bd9c7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
@@ -20,7 +20,6 @@ package org.apache.ambari.server.serveraction.upgrades;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.text.MessageFormat;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
@@ -42,18 +41,13 @@ import org.apache.ambari.server.orm.entities.HostVersionEntity;
 import org.apache.ambari.server.serveraction.AbstractServerAction;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.RepositoryVersionState;
-import org.apache.ambari.server.state.Service;
-import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.UpgradeState;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostSummary;
 import org.apache.commons.lang.StringUtils;
 
 import com.google.inject.Inject;
-import org.apache.commons.lang.text.StrBuilder;
 
 /**
  * Action that represents finalizing the Upgrade by completing any database changes.
@@ -179,8 +173,6 @@ public class FinalizeUpgradeAction extends AbstractServerAction {
         throw new AmbariException(message);
       }
 
-      checkHostComponentVesions(cluster, version, stack);
-
       // May need to first transition to UPGRADED
       if (atLeastOneHostInInstalledState) {
         cluster.transitionClusterVersion(stackId, version, RepositoryVersionState.UPGRADED);
@@ -311,52 +303,4 @@ public class FinalizeUpgradeAction extends AbstractServerAction {
     }
   }
 
-
-  /**
-   * Confirms that all host components that are able to provide hdp version,
-   * have been upgraded to the target version.
-   * @param cluster     the cluster the upgrade is for
-   * @param desiredVersion     the target version of the upgrade
-   * @throws AmbariException if any host component has not been updated yet
-   */
-  private void checkHostComponentVesions(Cluster cluster, String desiredVersion, StackId
stackId)
-          throws AmbariException {
-    class InfoTuple {
-      public InfoTuple(String serviceName, String componentName, String hostName) {
-        this.serviceName = serviceName;
-        this.componentName = componentName;
-        this.hostName = hostName;
-      }
-
-      public final String serviceName;
-      public final String componentName;
-      public final String hostName;
-    }
-    ArrayList<InfoTuple> errors = new ArrayList<InfoTuple>();
-    for (Service service : cluster.getServices().values()) {
-      for (ServiceComponent serviceComponent : service.getServiceComponents().values()) {
-        for (ServiceComponentHost serviceComponentHost : serviceComponent.getServiceComponentHosts().values())
{
-          ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-                  stackId.getStackVersion(), service.getName(), serviceComponent.getName());
-          if (componentInfo.isVersionAdvertised() && ! serviceComponentHost.getVersion().equals(desiredVersion))
{
-            errors.add(new InfoTuple(
-                    service.getName(), serviceComponent.getName(), serviceComponentHost.getHostName()));
-          }
-        }
-      }
-    }
-
-    if (! errors.isEmpty()) {
-      StrBuilder messageBuff = new StrBuilder(String.format("The following %d host component(s)
" +
-              "have not been upgraded to version %s. Please install and upgrade " +
-              "the Stack Version on those hosts and try again.\nHost components:\n",
-              errors.size(), desiredVersion));
-      for (InfoTuple error : errors) {
-        messageBuff.append(String.format("%s on host %s\n", error.componentName, error.hostName));
-      }
-      throw new AmbariException(messageBuff.toString());
-    }
-
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed3cd953/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 40274ac..540d58b 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -77,7 +77,6 @@
         "HostRoles/stale_configs",
         "HostRoles/desired_admin_state",
         "HostRoles/maintenance_state",
-        "HostRoles/hdp_version",
         "HostRoles/service_name",
         "_"
     ],

http://git-wip-us.apache.org/repos/asf/ambari/blob/ed3cd953/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
index 5581383..9bc7570 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
@@ -32,7 +32,6 @@ import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Service;
@@ -251,7 +250,6 @@ public class HostComponentResourceProviderTest {
     Resource.Type type = Resource.Type.HostComponent;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
-    HostVersionDAO hostVersionDAO = createMock(HostVersionDAO.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
     ResourceProviderFactory resourceProviderFactory = createNiceMock(ResourceProviderFactory.class);
     Injector injector = createNiceMock(Injector.class);
@@ -300,12 +298,10 @@ public class HostComponentResourceProviderTest {
     stageContainer.persist();
     expect(stageContainer.getRequestStatusResponse()).andReturn(response).once();
 
-    TestHostComponentResourceProvider provider =
+    HostComponentResourceProvider provider =
         new TestHostComponentResourceProvider(PropertyHelper.getPropertyIds(type),
             PropertyHelper.getKeyPropertyIds(type),
-            managementController, injector);
-    provider.setFieldValue("maintenanceStateHelper", maintenanceStateHelper);
-    provider.setFieldValue("hostVersionDAO", hostVersionDAO);
+            managementController, injector, maintenanceStateHelper);
 
     expect(resourceProviderFactory.getHostComponentResourceProvider(anyObject(Set.class),
         anyObject(Map.class),
@@ -356,7 +352,6 @@ public class HostComponentResourceProviderTest {
     ServiceComponentHost clientComponentHost = createNiceMock(ServiceComponentHost.class);
     RequestStageContainer stageContainer = createNiceMock(RequestStageContainer.class);
     MaintenanceStateHelper maintenanceStateHelper = createNiceMock(MaintenanceStateHelper.class);
-    HostVersionDAO hostVersionDAO = createMock(HostVersionDAO.class);
 
     Collection<String> hosts = new HashSet<String>();
     hosts.add("Host100");
@@ -397,7 +392,6 @@ public class HostComponentResourceProviderTest {
     expect(clientComponentHost.getHostName()).andReturn("Host100").anyTimes();
     expect(clientComponentHost.getServiceComponentName()).andReturn("some-client").anyTimes();
     expect(response.getMessage()).andReturn("response msg").anyTimes();
-    expect(hostVersionDAO.findByHostAndStateCurrent(anyObject(String.class), anyObject(String.class))).andReturn(null).anyTimes();
 
     //Cluster is default type.  Maintenance mode is not being tested here so the default
is returned.
     expect(maintenanceStateHelper.isOperationAllowed(Resource.Type.Cluster, componentHost)).andReturn(true).anyTimes();
@@ -430,22 +424,20 @@ public class HostComponentResourceProviderTest {
     expect(stageContainer.getProjectedState("Host100", "Component100")).andReturn(State.INSTALLED).once();
     expect(stageContainer.getRequestStatusResponse()).andReturn(response).once();
 
-    TestHostComponentResourceProvider provider =
+    HostComponentResourceProvider provider =
         new TestHostComponentResourceProvider(PropertyHelper.getPropertyIds(type),
             PropertyHelper.getKeyPropertyIds(type),
-            managementController, injector);
-    provider.setFieldValue("maintenanceStateHelper", maintenanceStateHelper);
-    provider.setFieldValue("hostVersionDAO", hostVersionDAO);
+            managementController, injector, maintenanceStateHelper);
 
     expect(resourceProviderFactory.getHostComponentResourceProvider(anyObject(Set.class),
-            anyObject(Map.class),
-            eq(managementController))).
+        anyObject(Map.class),
+        eq(managementController))).
         andReturn(provider).anyTimes();
 
     // replay
     replay(managementController, response, resourceProviderFactory, clusters, cluster, service,
         component, componentHost, stageContainer, maintenanceStateHelper, clientComponent,
-        clientComponentHost, hostVersionDAO);
+        clientComponentHost);
 
     Map<String, Object> properties = new LinkedHashMap<String, Object>();
     properties.put(HostComponentResourceProvider.HOST_COMPONENT_STATE_PROPERTY_ID, "STARTED");
@@ -557,8 +549,8 @@ public class HostComponentResourceProviderTest {
     HostComponentResourceProvider provider =
         new TestHostComponentResourceProvider(PropertyHelper.getPropertyIds(type),
             PropertyHelper.getKeyPropertyIds(type),
-            controller, injector);
-
+            controller, injector, injector.getInstance(MaintenanceStateHelper.class)
+        );
     RequestStageContainer requestStages = provider.updateHostComponents(null, requests, requestProperties,
runSmokeTest);
     requestStages.persist();
     return requestStages.getRequestStatusResponse();
@@ -574,16 +566,16 @@ public class HostComponentResourceProviderTest {
      * @param managementController the management controller
      */
     public TestHostComponentResourceProvider(Set<String> propertyIds, Map<Resource.Type,
String> keyPropertyIds,
-                                             AmbariManagementController managementController,
Injector injector) throws Exception {
+                                             AmbariManagementController managementController,
Injector injector,
+                                             MaintenanceStateHelper maintenanceStateHelper)
throws Exception {
+
       super(propertyIds, keyPropertyIds, managementController, injector);
-    }
 
-    public void setFieldValue(String fieldName, Object fieldValue) throws Exception {
       Class<?> c = getClass().getSuperclass();
-      Field f = c.getDeclaredField(fieldName);
+
+      Field f = c.getDeclaredField("maintenanceStateHelper");
       f.setAccessible(true);
-      f.set(this, fieldValue);
+      f.set(this, maintenanceStateHelper);
     }
-
   }
 }


Mime
View raw message