ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-17841. UI does not allow to delete service is some host components are in INSTALLED_FAILED state. (jaimin)
Date Wed, 27 Jul 2016 19:13:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 8ccf20d6e -> f301c46fd


AMBARI-17841. UI does not allow to delete service is some host components are in INSTALLED_FAILED
state. (jaimin)


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

Branch: refs/heads/branch-2.4
Commit: f301c46fddf804d2e8a9b2a199c1d207b22539d5
Parents: 8ccf20d
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Wed Jul 27 12:17:32 2016 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Wed Jul 27 12:17:40 2016 -0700

----------------------------------------------------------------------
 .../controller/ServiceComponentResponse.java    |  64 ++----------
 .../internal/ComponentResourceProvider.java     |  39 ++++---
 .../server/state/ServiceComponentImpl.java      |  45 ++++----
 .../src/main/resources/properties.json          |   3 +
 .../internal/ComponentResourceProviderTest.java | 104 ++++++++++++-------
 .../server/state/ServiceComponentTest.java      |  31 +++---
 .../app/controllers/global/update_controller.js |   2 +-
 ambari-web/app/controllers/main/service/item.js |  49 +++++----
 .../app/mappers/components_state_mapper.js      |   6 ++
 ambari-web/app/models/client_component.js       |  21 ++--
 10 files changed, 179 insertions(+), 185 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
index cb84b89..9dbda20 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
@@ -19,6 +19,8 @@
 package org.apache.ambari.server.controller;
 
 
+import java.util.Map;
+
 public class ServiceComponentResponse {
 
   private Long clusterId; // REF
@@ -37,11 +39,7 @@ public class ServiceComponentResponse {
 
   private String category;
 
-  private int totalCount;
-
-  private int startedCount;
-
-  private int installedCount;
+  Map<String, Integer> serviceComponentStateCount;
 
   private boolean recoveryEnabled;
 
@@ -50,9 +48,7 @@ public class ServiceComponentResponse {
                                   String componentName,
                                   String desiredStackVersion,
                                   String desiredState,
-                                  int totalCount,
-                                  int startedCount,
-                                  int installedCount,
+                                  Map<String, Integer> serviceComponentStateCount,
                                   boolean recoveryEnabled,
                                   String displayName) {
     super();
@@ -63,9 +59,7 @@ public class ServiceComponentResponse {
     this.displayName = displayName;
     this.desiredStackVersion = desiredStackVersion;
     this.desiredState = desiredState;
-    this.totalCount = totalCount;
-    this.startedCount = startedCount;
-    this.installedCount = installedCount;
+    this.serviceComponentStateCount = serviceComponentStateCount;
     this.recoveryEnabled = recoveryEnabled;
   }
 
@@ -179,51 +173,11 @@ public class ServiceComponentResponse {
   }
 
   /**
-   * Get the number of started SCH's
-   * @return number of started SCH's
-   */
-  public int getStartedCount() {
-    return startedCount;
-  }
-
-  /**
-   * Set the number of started SCH's
-   * @param startedCount
-   */
-  public void setStartedCount(int startedCount) {
-    this.startedCount = startedCount;
-  }
-
-  /**
-   * Get the number of installed SCH's
-   * @return number of installed SCH's
-   */
-  public int getInstalledCount() {
-    return installedCount;
-  }
-
-  /**
-   * Set the number of installed SCH's
-   * @param installedCount
-   */
-  public void setInstalledCount(int installedCount) {
-    this.installedCount = installedCount;
-  }
-
-  /**
-   * Get the total number of SCH's
-   * @return
-   */
-  public int getTotalCount() {
-    return totalCount;
-  }
-
-  /**
-   * Set the total number of SCH's
-   * @param totalCount
+   * Get the count of service component for each state
+   * @return number of service component for each state
    */
-  public void setTotalCount(int totalCount) {
-    this.totalCount = totalCount;
+  public Map<String, Integer> getServiceComponentStateCount() {
+    return serviceComponentStateCount;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index cc13e39..c80881f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -17,16 +17,9 @@
  */
 package org.apache.ambari.server.controller.internal;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import com.google.inject.persist.Transactional;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ClusterNotFoundException;
 import org.apache.ambari.server.DuplicateResourceException;
@@ -61,13 +54,19 @@ import org.apache.ambari.server.state.ServiceComponentFactory;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
-
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-import com.google.inject.persist.Transactional;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.Validate;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * Resource provider for component resources.
  */
@@ -85,6 +84,9 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
   protected static final String COMPONENT_TOTAL_COUNT_PROPERTY_ID     = "ServiceComponentInfo/total_count";
   protected static final String COMPONENT_STARTED_COUNT_PROPERTY_ID   = "ServiceComponentInfo/started_count";
   protected static final String COMPONENT_INSTALLED_COUNT_PROPERTY_ID = "ServiceComponentInfo/installed_count";
+  protected static final String COMPONENT_INIT_COUNT_PROPERTY_ID      = "ServiceComponentInfo/init_count";
+  protected static final String COMPONENT_UNKNOWN_COUNT_PROPERTY_ID   = "ServiceComponentInfo/unknown_count";
+  protected static final String COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID = "ServiceComponentInfo/install_failed_count";
   protected static final String COMPONENT_RECOVERY_ENABLED_ID         = "ServiceComponentInfo/recovery_enabled";
 
   private static final String TRUE = "true";
@@ -178,9 +180,12 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
       setResourceProperty(resource, COMPONENT_DISPLAY_NAME_PROPERTY_ID, response.getDisplayName(),
requestedIds);
       setResourceProperty(resource, COMPONENT_STATE_PROPERTY_ID, response.getDesiredState(),
requestedIds);
       setResourceProperty(resource, COMPONENT_CATEGORY_PROPERTY_ID, response.getCategory(),
requestedIds);
-      setResourceProperty(resource, COMPONENT_TOTAL_COUNT_PROPERTY_ID, response.getTotalCount(),
requestedIds);
-      setResourceProperty(resource, COMPONENT_STARTED_COUNT_PROPERTY_ID, response.getStartedCount(),
requestedIds);
-      setResourceProperty(resource, COMPONENT_INSTALLED_COUNT_PROPERTY_ID, response.getInstalledCount(),
requestedIds);
+      setResourceProperty(resource, COMPONENT_TOTAL_COUNT_PROPERTY_ID, response.getServiceComponentStateCount().get("totalCount"),
requestedIds);
+      setResourceProperty(resource, COMPONENT_STARTED_COUNT_PROPERTY_ID, response.getServiceComponentStateCount().get("startedCount"),
requestedIds);
+      setResourceProperty(resource, COMPONENT_INSTALLED_COUNT_PROPERTY_ID, response.getServiceComponentStateCount().get("installedCount"),
requestedIds);
+      setResourceProperty(resource, COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID, response.getServiceComponentStateCount().get("installFailedCount"),
requestedIds);
+      setResourceProperty(resource, COMPONENT_INIT_COUNT_PROPERTY_ID, response.getServiceComponentStateCount().get("initCount"),
requestedIds);
+      setResourceProperty(resource, COMPONENT_UNKNOWN_COUNT_PROPERTY_ID, response.getServiceComponentStateCount().get("unknownCount"),
requestedIds);
       setResourceProperty(resource, COMPONENT_RECOVERY_ENABLED_ID, String.valueOf(response.isRecoveryEnabled()),
requestedIds);
 
       resources.add(resource);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 9283e38..3e805a0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -18,12 +18,12 @@
 
 package org.apache.ambari.server.state;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.ProvisionException;
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import com.google.inject.persist.Transactional;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.ServiceComponentHostNotFoundException;
@@ -46,12 +46,11 @@ import org.apache.ambari.server.state.cluster.ClusterImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.ProvisionException;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-import com.google.inject.persist.Transactional;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 public class ServiceComponentImpl implements ServiceComponent {
 
@@ -522,8 +521,7 @@ public class ServiceComponentImpl implements ServiceComponent {
       ServiceComponentResponse r = new ServiceComponentResponse(getClusterId(),
           cluster.getClusterName(), service.getName(), getName(),
           getDesiredStackVersion().getStackId(), getDesiredState().toString(),
-          getTotalCount(), getStartedCount(), getInstalledCount(),
-          isRecoveryEnabled(), displayName);
+          getServiceComponentStateCount(), isRecoveryEnabled(), displayName);
       return r;
     } finally {
       readWriteLock.readLock().unlock();
@@ -808,16 +806,15 @@ public class ServiceComponentImpl implements ServiceComponent {
     return count;
   }
 
-  private int getStartedCount() {
-    return getSCHCountByState(State.STARTED);
-  }
-
-  private int getInstalledCount() {
-    return getSCHCountByState(State.INSTALLED);
-  }
-
-  private int getTotalCount() {
-    return hostComponents.size();
+  private Map <String, Integer> getServiceComponentStateCount() {
+    Map <String, Integer> serviceComponentStateCountMap = new HashMap <String, Integer>();
+    serviceComponentStateCountMap.put("startedCount", getSCHCountByState(State.STARTED));
+    serviceComponentStateCountMap.put("installedCount", getSCHCountByState(State.INSTALLED));
+    serviceComponentStateCountMap.put("installFailedCount", getSCHCountByState(State.INSTALL_FAILED));
+    serviceComponentStateCountMap.put("initCount", getSCHCountByState(State.INIT));
+    serviceComponentStateCountMap.put("unknownCount", getSCHCountByState(State.UNKNOWN));
+    serviceComponentStateCountMap.put("totalCount", hostComponents.size());
+    return serviceComponentStateCountMap;
   }
 
   // Refresh cached reference after ever setter

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/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 f471628..eb27878 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -63,6 +63,9 @@
         "ServiceComponentInfo/total_count",
         "ServiceComponentInfo/started_count",
         "ServiceComponentInfo/installed_count",
+        "ServiceComponentInfo/install_failed_count",
+        "ServiceComponentInfo/init_count",
+        "ServiceComponentInfo/unknown_count",
         "ServiceComponentInfo/recovery_enabled",
         "params/run_smoke_test",
         "_"

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index cbf3044..e4cc3de 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -18,31 +18,8 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.gson.Gson;
+import com.google.inject.Injector;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
@@ -79,12 +56,34 @@ import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-
-import com.google.gson.Gson;
-import com.google.inject.Injector;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /**
  * Tests for the component resource provider.
  */
@@ -215,6 +214,13 @@ public class ComponentResourceProviderTest {
     StackId stackId = createNiceMock(StackId.class);
     final ComponentInfo componentInfo1 = createNiceMock(ComponentInfo.class);
     final ComponentInfo componentInfo2 = createNiceMock(ComponentInfo.class);
+    Map <String, Integer> serviceComponentStateCountMap = new HashMap <String, Integer>();
+    serviceComponentStateCountMap.put("startedCount", 1);
+    serviceComponentStateCountMap.put("installedCount", 0);
+    serviceComponentStateCountMap.put("installFailedCount", 0);
+    serviceComponentStateCountMap.put("initCount", 0);
+    serviceComponentStateCountMap.put("unknownCount", 1);
+    serviceComponentStateCountMap.put("totalCount", 2);
 
     Map<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
     serviceComponentMap.put("Component101", serviceComponent1);
@@ -235,13 +241,13 @@ public class ComponentResourceProviderTest {
     expect(service.getServiceComponents()).andReturn(serviceComponentMap).anyTimes();
 
     expect(serviceComponent1.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null,
"", 1, 1, 0,
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null,
"", serviceComponentStateCountMap,
               true /* recovery enabled */, "Component100 Client"));
     expect(serviceComponent2.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null,
"", 1, 1, 0,
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null,
"", serviceComponentStateCountMap,
               false /* recovery not enabled */, "Component101 Client"));
     expect(serviceComponent3.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null,
"", 1, 1, 0,
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null,
"", serviceComponentStateCountMap,
               true /* recovery enabled */, "Component102 Client"));
 
     expect(ambariMetaInfo.getComponent(null, null, null, "Component100")).andReturn(componentInfo1);
@@ -271,6 +277,9 @@ public class ComponentResourceProviderTest {
     propertyIds.add(ComponentResourceProvider.COMPONENT_TOTAL_COUNT_PROPERTY_ID);
     propertyIds.add(ComponentResourceProvider.COMPONENT_STARTED_COUNT_PROPERTY_ID);
     propertyIds.add(ComponentResourceProvider.COMPONENT_INSTALLED_COUNT_PROPERTY_ID);
+    propertyIds.add(ComponentResourceProvider.COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID);
+    propertyIds.add(ComponentResourceProvider.COMPONENT_INIT_COUNT_PROPERTY_ID);
+    propertyIds.add(ComponentResourceProvider.COMPONENT_UNKNOWN_COUNT_PROPERTY_ID);
     propertyIds.add(ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID);
 
     Predicate predicate = new PredicateBuilder()
@@ -290,12 +299,18 @@ public class ComponentResourceProviderTest {
       Assert.assertEquals("Cluster100", clusterName);
       Assert.assertEquals("MASTER", resource.getPropertyValue(
           ComponentResourceProvider.COMPONENT_CATEGORY_PROPERTY_ID));
-      Assert.assertEquals(1, resource.getPropertyValue(
+      Assert.assertEquals(2, resource.getPropertyValue(
         ComponentResourceProvider.COMPONENT_TOTAL_COUNT_PROPERTY_ID));
       Assert.assertEquals(1, resource.getPropertyValue(
         ComponentResourceProvider.COMPONENT_STARTED_COUNT_PROPERTY_ID));
       Assert.assertEquals(0, resource.getPropertyValue(
         ComponentResourceProvider.COMPONENT_INSTALLED_COUNT_PROPERTY_ID));
+      Assert.assertEquals(0, resource.getPropertyValue(
+          ComponentResourceProvider.COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID));
+      Assert.assertEquals(0, resource.getPropertyValue(
+          ComponentResourceProvider.COMPONENT_INIT_COUNT_PROPERTY_ID));
+      Assert.assertEquals(1, resource.getPropertyValue(
+          ComponentResourceProvider.COMPONENT_UNKNOWN_COUNT_PROPERTY_ID));
       Assert.assertEquals(String.valueOf(true), resource.getPropertyValue(
         ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID));
     }
@@ -346,6 +361,14 @@ public class ComponentResourceProviderTest {
     serviceComponentMap.put("Component102", serviceComponent2);
     serviceComponentMap.put("Component103", serviceComponent3);
 
+    Map <String, Integer> serviceComponentStateCountMap = new HashMap <String, Integer>();
+    serviceComponentStateCountMap.put("startedCount", 0);
+    serviceComponentStateCountMap.put("installedCount", 1);
+    serviceComponentStateCountMap.put("installFailedCount", 0);
+    serviceComponentStateCountMap.put("initCount", 0);
+    serviceComponentStateCountMap.put("unknownCount", 0);
+    serviceComponentStateCountMap.put("totalCount", 1);
+
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
@@ -380,13 +403,13 @@ public class ComponentResourceProviderTest {
     expect(component3Info.getCategory()).andReturn(null);
 
     expect(serviceComponent1.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null,
"", 1, 0, 1,
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null,
"", serviceComponentStateCountMap,
               false /* recovery not enabled */, "Component101 Client"));
     expect(serviceComponent2.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null,
"", 1, 0, 1,
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null,
"", serviceComponentStateCountMap,
               false /* recovery not enabled */, "Component102 Client"));
     expect(serviceComponent3.convertToResponse()).andReturn(
-      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null,
"", 1, 0, 1,
+      new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null,
"", serviceComponentStateCountMap,
               false /* recovery not enabled */, "Component103 Client"));
     expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
     expect(serviceComponent2.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
@@ -656,6 +679,15 @@ public class ComponentResourceProviderTest {
     Map<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
     serviceComponentMap.put("Component101", serviceComponent1);
 
+    Map <String, Integer> serviceComponentStateCountMap = new HashMap <String, Integer>();
+    serviceComponentStateCountMap.put("startedCount", 0);
+    serviceComponentStateCountMap.put("installedCount", 1);
+    serviceComponentStateCountMap.put("installFailedCount", 0);
+    serviceComponentStateCountMap.put("initCount", 0);
+    serviceComponentStateCountMap.put("unknownCount", 0);
+    serviceComponentStateCountMap.put("totalCount", 1);
+
+
     // set expectations
     expect(managementController.getClusters()).andReturn(clusters).anyTimes();
     expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
@@ -687,7 +719,7 @@ public class ComponentResourceProviderTest {
     expect(component1Info.getCategory()).andReturn(null);
 
     expect(serviceComponent1.convertToResponse()).andReturn(
-        new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null,
"", 1, 0, 1,
+        new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null,
"", serviceComponentStateCountMap,
             false /* recovery not enabled */, "Component101 Client"));
     expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
index 22cf302..b043da1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
@@ -18,14 +18,10 @@
 
 package org.apache.ambari.server.state;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
+import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.ServiceComponentResponse;
@@ -50,11 +46,13 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.persist.PersistService;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 public class ServiceComponentTest {
 
@@ -327,9 +325,12 @@ public class ServiceComponentTest {
         r.getDesiredStackVersion());
     Assert.assertEquals(sc.getDesiredState().toString(),
         r.getDesiredState());
-    Assert.assertEquals(1, r.getTotalCount());
-    Assert.assertEquals(0, r.getStartedCount());
-    Assert.assertEquals(1, r.getInstalledCount());
+    int totalCount = r.getServiceComponentStateCount().get("totalCount");
+    int startedCount = r.getServiceComponentStateCount().get("startedCount");
+    int installedCount = r.getServiceComponentStateCount().get("installedCount");
+    Assert.assertEquals(1, totalCount);
+    Assert.assertEquals(0, startedCount);
+    Assert.assertEquals(1, installedCount);
 
     // TODO check configs
     // r.getConfigVersions()

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index e179a2a..68e6ba3 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -542,7 +542,7 @@ App.UpdateController = Em.Controller.extend({
   updateComponentsState: function (callback) {
     var testUrl = '/data/services/HDP2/components_state.json';
     var realUrl = '/components/?fields=ServiceComponentInfo/service_name,' +
-      'ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/started_count,ServiceComponentInfo/total_count,ServiceComponentInfo/display_name,host_components/HostRoles/host_name&minimal_response=true';
+      'ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/started_count,ServiceComponentInfo/init_count,ServiceComponentInfo/install_failed_count,ServiceComponentInfo/unknown_count,ServiceComponentInfo/total_count,ServiceComponentInfo/display_name,host_components/HostRoles/host_name&minimal_response=true';
     var url = this.getUrl(testUrl, realUrl);
 
     App.HttpClient.get(url, App.componentsStateMapper, {

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index ce0b240..e3df70b 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -1270,30 +1270,35 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
       });
     } else if (dependentServices.length > 0) {
       this.dependentServicesWarning(serviceName, dependentServices);
-    } else if (this.allowUninstallServices(serviceNamesToDelete)) {
-      if (serviceName === 'RANGER_KMS') {
-        App.showConfirmationPopup(
-          function() {self.showLastWarning(serviceName, interDependentServices, dependentServicesToDeleteFmt)},
-          Em.I18n.t('services.service.delete.popup.warning.ranger_kms'),
-          null,
-          popupHeader,
-          Em.I18n.t('common.delete'),
-          true
-        );
-      } else {
-        this.showLastWarning(serviceName, interDependentServices, dependentServicesToDeleteFmt);
-      }
     } else {
-      var body = Em.I18n.t('services.service.delete.popup.mustBeStopped').format(displayName);
-      if (interDependentServices.length) {
-        body += Em.I18n.t('services.service.delete.popup.mustBeStopped.dependent').format(dependentServicesToDeleteFmt)
+      var isServiceInRemovableState = this.allowUninstallServices(serviceNamesToDelete);
+      if (isServiceInRemovableState) {
+        if (serviceName === 'RANGER_KMS') {
+          App.showConfirmationPopup(
+            function () {
+              self.showLastWarning(serviceName, interDependentServices, dependentServicesToDeleteFmt)
+            },
+            Em.I18n.t('services.service.delete.popup.warning.ranger_kms'),
+            null,
+            popupHeader,
+            Em.I18n.t('common.delete'),
+            true
+          );
+        } else {
+          this.showLastWarning(serviceName, interDependentServices, dependentServicesToDeleteFmt);
+        }
+      } else {
+        var body = Em.I18n.t('services.service.delete.popup.mustBeStopped').format(displayName);
+        if (interDependentServices.length) {
+          body += Em.I18n.t('services.service.delete.popup.mustBeStopped.dependent').format(dependentServicesToDeleteFmt)
+        }
+        App.ModalPopup.show({
+          secondary: null,
+          header: popupHeader,
+          encodeBody: false,
+          body: body
+        });
       }
-      App.ModalPopup.show({
-        secondary: null,
-        header: popupHeader,
-        encodeBody: false,
-        body: body
-      });
     }
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-web/app/mappers/components_state_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/components_state_mapper.js b/ambari-web/app/mappers/components_state_mapper.js
index 3ad8e49..b86aee5 100644
--- a/ambari-web/app/mappers/components_state_mapper.js
+++ b/ambari-web/app/mappers/components_state_mapper.js
@@ -31,6 +31,9 @@ App.componentsStateMapper = App.QuickDataMapper.create({
     display_name: 'ServiceComponentInfo.display_name',
     service_name: 'ServiceComponentInfo.service_name',
     installed_count: 'ServiceComponentInfo.installed_count',
+    install_failed_count: 'ServiceComponentInfo.install_failed_count',
+    init_count: 'ServiceComponentInfo.init_count',
+    unknown_count: 'ServiceComponentInfo.unknown_count',
     started_count: 'ServiceComponentInfo.started_count',
     total_count: 'ServiceComponentInfo.total_count',
     host_names: 'host_names'
@@ -41,6 +44,9 @@ App.componentsStateMapper = App.QuickDataMapper.create({
 
   paths: {
     INSTALLED_PATH: 'ServiceComponentInfo.installed_count',
+    INSTALL_FAILED_PATH: 'ServiceComponentInfo.install_failed_count',
+    INIT_PATH: 'ServiceComponentInfo.init_count',
+    UNKNOWN_PATH: 'ServiceComponentInfo.unknown_count',
     STARTED_PATH: 'ServiceComponentInfo.started_count',
     TOTAL_PATH: 'ServiceComponentInfo.total_count'
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/f301c46f/ambari-web/app/models/client_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/client_component.js b/ambari-web/app/models/client_component.js
index 3902227..19ef7ce 100644
--- a/ambari-web/app/models/client_component.js
+++ b/ambari-web/app/models/client_component.js
@@ -24,31 +24,22 @@ App.ClientComponent = DS.Model.extend({
   componentName: DS.attr('string'),
   displayName: DS.attr('string'),
   installedCount: DS.attr('number'),
+  installFailedCount: DS.attr('number'),
+  initCount: DS.attr('number'),
+  unknownCount: DS.attr('number'),
   startedCount: DS.attr('number'),
   totalCount: DS.attr('number'),
   stackInfo: DS.belongsTo('App.StackServiceComponent'),
   hostNames: DS.attr('array'),
 
   /**
-   * Defines if all components are in 'INSTALLED' state
-   *
-   * @type {boolean}
-   */
-  allStopped: Em.computed.equalProperties('installedCount', 'totalCount'),
-
-  /**
-   * No stated and no installed component
-   *
-   * @type {boolean}
-   */
-  noOneInstalled: Em.computed.and('!installedCount', '!startedCount'),
-
-  /**
    * Determines if component may be deleted
    *
    * @type {boolean}
    */
-  allowToDelete: Em.computed.or('allStopped', 'noOneInstalled'),
+  allowToDelete: function() {
+    return this.get('totalCount') === (this.get('installedCount') + this.get('installFailedCount')
+ this.get('initCount') + this.get('unknownCount'));
+  }.property('totalCount', 'installedCount', 'installFailedCount', 'initCount', 'unknownCount'),
 
   summaryLabelClassName:function(){
     return 'label_for_'+this.get('componentName').toLowerCase();


Mime
View raw message