incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject svn commit: r1485074 - in /incubator/ambari/trunk: ./ ambari-server/src/main/java/org/apache/ambari/server/api/services/ ambari-server/src/main/java/org/apache/ambari/server/controller/ ambari-server/src/main/java/org/apache/ambari/server/controller/in...
Date Wed, 22 May 2013 06:11:41 GMT
Author: smohanty
Date: Wed May 22 06:11:40 2013
New Revision: 1485074

URL: http://svn.apache.org/r1485074
Log:
AMBARI-2182. Expose -active- attribute for Stack resource. (smohanty)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
    incubator/ambari/trunk/ambari-server/src/main/resources/properties.json
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1485074&r1=1485073&r2=1485074&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Wed May 22 06:11:40 2013
@@ -873,6 +873,8 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-2182. Expose "active" attribute for Stack resource. (smohanty)
+
  AMBARI-2181. keys/pass.txt file is readable by everyone. (smohanty)
 
  AMBARI-2177. HBase Smoke Test shows success even if it fails. (smohanty)

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java?rev=1485074&r1=1485073&r2=1485074&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
Wed May 22 06:11:40 2013
@@ -52,6 +52,7 @@ public class AmbariMetaInfo {
   private static final String STACK_METAINFO_FILE_NAME = "metainfo.xml";
   private static final String STACK_XML_MAIN_BLOCK_NAME = "metainfo";
   private static final String STACK_XML_PROPERTY_UPGRADE = "upgrade";
+  private static final String STACK_XML_PROPERTY_ACTIVE = "active";
   private static final String SERVICES_FOLDER_NAME = "services";
   private static final String SERVICE_METAINFO_FILE_NAME = "metainfo.xml";
   private static final String SERVICE_CONFIG_FOLDER_NAME = "configuration";
@@ -709,6 +710,9 @@ public class AmbariMetaInfo {
 
             stackInfo.setMinUpgradeVersion(getTagValue(
                 STACK_XML_PROPERTY_UPGRADE, property));
+
+            stackInfo.setActive(Boolean.parseBoolean(getTagValue(
+                STACK_XML_PROPERTY_ACTIVE, property)));
           }
         }
       } catch (Exception e) {

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java?rev=1485074&r1=1485073&r2=1485074&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/StackVersionResponse.java
Wed May 22 06:11:40 2013
@@ -26,11 +26,14 @@ public class StackVersionResponse {
 
   private String stackVersion;
   private String minUpgradeVersion;
+  private boolean active;
   private List<RepositoryInfo> repositories;
 
-  public StackVersionResponse(String stackVersion, String minUpgradeVersion) {
+  public StackVersionResponse(String stackVersion, String minUpgradeVersion,
+                              boolean active) {
     setStackVersion(stackVersion);
     setMinUpgradeVersion(minUpgradeVersion);
+    setActive(active);
   }
 
   public String getStackVersion() {
@@ -56,4 +59,12 @@ public class StackVersionResponse {
   public void setMinUpgradeVersion(String minUpgradeVersion) {
     this.minUpgradeVersion = minUpgradeVersion;
   }
+
+  public boolean isActive() {
+    return active;
+  }
+
+  public void setActive(boolean active) {
+    this.active = active;
+  }
 }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java?rev=1485074&r1=1485073&r2=1485074&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
Wed May 22 06:11:40 2013
@@ -57,6 +57,9 @@ public class StackVersionResourceProvide
   private static final String STACK_MIN_VERSION_PROPERTY_ID = PropertyHelper
       .getPropertyId("Versions", "min_upgrade_version");
 
+  private static final String STACK_ACTIVE_PROPERTY_ID = PropertyHelper
+      .getPropertyId("Versions", "active");
+
   private static Set<String> pkPropertyIds = new HashSet<String>(
       Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
           STACK_VERSION_PROPERTY_ID }));
@@ -93,6 +96,9 @@ public class StackVersionResourceProvide
       setResourceProperty(resource, STACK_MIN_VERSION_PROPERTY_ID,
           response.getMinUpgradeVersion(), requestedIds);
 
+      setResourceProperty(resource, STACK_ACTIVE_PROPERTY_ID,
+          response.isActive(), requestedIds);
+
       resources.add(resource);
     }
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java?rev=1485074&r1=1485073&r2=1485074&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/StackInfo.java
Wed May 22 06:11:40 2013
@@ -27,6 +27,7 @@ public class StackInfo {
   private String name;
   private String version;
   private String minUpgradeVersion;
+  private boolean active;
   private List<RepositoryInfo> repositories;
   private List<ServiceInfo> services;
 
@@ -66,7 +67,8 @@ public class StackInfo {
 
   @Override
   public String toString() {
-    StringBuilder sb = new StringBuilder("Stack name:" + name + "\nversion:" + version );//TODO
add repository
+    StringBuilder sb = new StringBuilder("Stack name:" + name + "\nversion:" +
+      version + "\nactive:" + active);
     if (services != null) {
       sb.append("\n\t\tService:");
       for (ServiceInfo service : services) {
@@ -106,7 +108,7 @@ public class StackInfo {
 
   public StackVersionResponse convertToResponse() {
 
-    return new StackVersionResponse(getVersion(), getMinUpgradeVersion());
+    return new StackVersionResponse(getVersion(), getMinUpgradeVersion(), isActive());
   }
 
   public String getMinUpgradeVersion() {
@@ -116,4 +118,12 @@ public class StackInfo {
   public void setMinUpgradeVersion(String minUpgradeVersion) {
     this.minUpgradeVersion = minUpgradeVersion;
   }
+
+  public boolean isActive() {
+    return active;
+  }
+
+  public void setActive(boolean active) {
+    this.active = active;
+  }
 }

Modified: incubator/ambari/trunk/ambari-server/src/main/resources/properties.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/properties.json?rev=1485074&r1=1485073&r2=1485074&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/resources/properties.json (original)
+++ incubator/ambari/trunk/ambari-server/src/main/resources/properties.json Wed May 22 06:11:40
2013
@@ -118,6 +118,7 @@
         "Versions/stack_name",
         "Versions/stack_version",
         "Versions/min_upgrade_version",
+        "Versions/active",
         "_"
     ],
     "OperatingSystem":[

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java?rev=1485074&r1=1485073&r2=1485074&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
Wed May 22 06:11:40 2013
@@ -56,21 +56,7 @@ import org.apache.ambari.server.security
 import org.apache.ambari.server.serveraction.ServerAction;
 import org.apache.ambari.server.serveraction.ServerActionManager;
 import org.apache.ambari.server.serveraction.ServerActionManagerImpl;
-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.ConfigFactory;
-import org.apache.ambari.server.state.ConfigImpl;
-import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.HostState;
-import org.apache.ambari.server.state.Service;
-import org.apache.ambari.server.state.ServiceComponent;
-import org.apache.ambari.server.state.ServiceComponentFactory;
-import org.apache.ambari.server.state.ServiceComponentHost;
-import org.apache.ambari.server.state.ServiceComponentHostFactory;
-import org.apache.ambari.server.state.ServiceFactory;
-import org.apache.ambari.server.state.StackId;
-import org.apache.ambari.server.state.State;
+import org.apache.ambari.server.state.*;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent;
 import org.apache.ambari.server.utils.StageUtils;
 import org.junit.After;
@@ -5290,6 +5276,22 @@ public class AmbariManagementControllerT
     }
   }
 
+  @Test
+  public void testGetStackVersionActiveAttr() throws Exception {
+
+    for (StackInfo stackInfo: ambariMetaInfo.getStackInfos(STACK_NAME)) {
+      if (stackInfo.getVersion().equalsIgnoreCase(STACK_VERSION)) {
+        stackInfo.setActive(true);
+      }
+    }
+
+    StackVersionRequest requestWithParams = new StackVersionRequest(STACK_NAME, STACK_VERSION);
+    Set<StackVersionResponse> responsesWithParams = controller.getStackVersions(Collections.singleton(requestWithParams));
+    Assert.assertEquals(1, responsesWithParams.size());
+    for (StackVersionResponse responseWithParams: responsesWithParams) {
+      Assert.assertTrue(responseWithParams.isActive());
+    }
+  }
 
   @Test
   public void testGetRepositories() throws Exception {



Mime
View raw message