stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [4/4] stratos git commit: Update cartridge group
Date Sun, 09 Aug 2015 13:19:36 GMT
Update cartridge group


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

Branch: refs/heads/tenant-isolation
Commit: 6ce6d54703892ecd471b62a526e127b6ea682128
Parents: d2137f4
Author: Gayan Gunarathne <gayang@wso2.com>
Authored: Sun Aug 9 18:49:14 2015 +0530
Committer: Gayan Gunarathne <gayang@wso2.com>
Committed: Sun Aug 9 18:49:14 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41Utils.java     | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/6ce6d547/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index cd88624..aa4239d 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -1034,7 +1034,7 @@ public class StratosApiV41Utils {
             log.debug("Checking cartridges in cartridge group " + cartridgeGroupUuid);
         }
 
-        findCartridgesInGroupBean(serviceGroupDefinition, cartridgeTypes);
+
 
         //validate the group definition to check if cartridges duplicate in any groups defined
         validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
@@ -1107,7 +1107,7 @@ public class StratosApiV41Utils {
 
         ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(
                 serviceGroupDefinition,UUID.randomUUID().toString(), tenantId);
-
+        findCartridgesInGroupBean(serviceGroup, cartridgeTypes);
         AutoscalerServiceClient asServiceClient = getAutoscalerServiceClient();
         try {
             asServiceClient.addServiceGroup(serviceGroup);
@@ -1155,15 +1155,15 @@ public class StratosApiV41Utils {
             validateGroupDuplicationInGroupDefinition(cartridgeGroup);
 
             if (existingServiceGroup != null) {
-                autoscalerServiceClient.updateServiceGroup(
-                        ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(cartridgeGroup,existingServiceGroup.getUuid(),
tenantId));
+                ServiceGroup serviceGroup= ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(cartridgeGroup,
existingServiceGroup.getUuid(), tenantId);
+                autoscalerServiceClient.updateServiceGroup(serviceGroup);
 
                 List<String> cartridgesBeforeUpdating = new ArrayList<String>();
                 List<String> cartridgesAfterUpdating = new ArrayList<String>();
 
                 ServiceGroup serviceGroupToBeUpdated = autoscalerServiceClient.getServiceGroup(existingServiceGroup.getUuid());
                 findCartridgesInServiceGroup(serviceGroupToBeUpdated, cartridgesBeforeUpdating);
-                findCartridgesInGroupBean(cartridgeGroup, cartridgesAfterUpdating);
+                findCartridgesInGroupBean(serviceGroup, cartridgesAfterUpdating);
 
                 List<String> cartridgesToRemove = new ArrayList<String>();
                 List<String> cartridgesToAdd = new ArrayList<String>();
@@ -1388,7 +1388,7 @@ public class StratosApiV41Utils {
             for (String cartridgeName : serviceGroup.getCartridges()) {
                 cartridgeUuid = CloudControllerServiceClient.getInstance().getCartridgeByTenant(cartridgeName,
                         carbonContext.getTenantId()).getUuid();
-                if (cartridgeName != null && (!cartridgeNames.contains(cartridgeUuid)))
{
+                if (cartridgeName != null && (!cartridgeNames.contains(cartridgeName)))
{
 
                     cartridgeNames.add(cartridgeUuid);
                 }
@@ -1408,7 +1408,7 @@ public class StratosApiV41Utils {
      * @param groupBean  groupBean
      * @param cartridges List of cartridges
      */
-    private static void findCartridgesInGroupBean(CartridgeGroupBean groupBean, List<String>
cartridges) {
+    private static void findCartridgesInGroupBean(ServiceGroup groupBean, List<String>
cartridges) {
 
         if (groupBean == null || cartridges == null) {
             return;
@@ -1417,13 +1417,13 @@ public class StratosApiV41Utils {
         if (groupBean.getCartridges() != null) {
             for (String cartridge : groupBean.getCartridges()) {
                 if (!cartridges.contains(cartridge)) {
-                    cartridges.add(cartridge);
+                    cartridges.add(groupBean.getUuid());
                 }
             }
         }
 
         if (groupBean.getGroups() != null) {
-            for (CartridgeGroupBean seGroup : groupBean.getGroups()) {
+            for (ServiceGroup seGroup : groupBean.getGroups()) {
                 findCartridgesInGroupBean(seGroup, cartridges);
             }
         }


Mime
View raw message