You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/08/11 13:03:03 UTC
[2/2] stratos git commit: Fixing issues in Service Group updation
Fixing issues in Service Group updation
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7dc73365
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7dc73365
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7dc73365
Branch: refs/heads/tenant-isolation
Commit: 7dc733655256e75d3c38ddf4bafe004672fbfaea
Parents: efa9ce5
Author: Dinithi <di...@wso2.com>
Authored: Tue Aug 11 14:54:51 2015 +0530
Committer: Dinithi <di...@wso2.com>
Committed: Tue Aug 11 14:54:51 2015 +0530
----------------------------------------------------------------------
.../client/CloudControllerServiceClient.java | 4 +--
.../rest/endpoint/api/StratosApiV41Utils.java | 38 ++++++++------------
.../application/ApplicationBurstingTest.java | 6 ++--
.../application/SingleClusterScalingTest.java | 6 ++--
.../tests/group/CartridgeGroupTest.java | 10 +++---
5 files changed, 27 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/7dc73365/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
index 0bd9272..dea1e3a 100644
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java
@@ -120,9 +120,9 @@ public class CloudControllerServiceClient {
return stub.getCartridgesByTenant(tenantId);
}
- public Cartridge getCartridge(String cartridgeType) throws RemoteException,
+ public Cartridge getCartridge(String cartridgeUuid) throws RemoteException,
CloudControllerServiceCartridgeNotFoundExceptionException {
- return stub.getCartridge(cartridgeType);
+ return stub.getCartridge(cartridgeUuid);
}
public Cartridge getCartridgeByTenant(String cartridgeType,int tenantId) throws RemoteException,
http://git-wip-us.apache.org/repos/asf/stratos/blob/7dc73365/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 d67fe4b..5c9ab69 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
@@ -1035,7 +1035,11 @@ public class StratosApiV41Utils {
ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup
(serviceGroupDefinition,UUID.randomUUID().toString(), tenantId);
- findCartridgesInGroupBean(serviceGroup, cartridgeTypes);
+ try {
+ findCartridgesInGroupBean(serviceGroup, cartridgeTypes);
+ } catch (RemoteException e) {
+ throw new RestAPIException(e.getMessage());
+ }
//validate the group definition to check if cartridges duplicate in any groups defined
validateCartridgeDuplicationInGroupDefinition(serviceGroupDefinition);
@@ -1051,30 +1055,13 @@ public class StratosApiV41Utils {
throw new RestAPIException(message, e);
}
-
- CloudControllerServiceClient ccServiceClient = getCloudControllerServiceClient();
-
cartridgeUuids = new String[cartridgeTypes.size()];
int j = 0;
- for (String cartridgeType : cartridgeTypes) {
- try {
- Cartridge cartridge = ccServiceClient.getCartridgeByTenant(cartridgeType, tenantId);
- if (cartridge == null) {
- // cartridge is not deployed, can't continue
- log.error("Invalid cartridge found in cartridge group " + cartridgeType);
- throw new InvalidCartridgeException();
- } else {
- cartridgeUuids[j] = cartridge.getUuid();
- j++;
- }
- } catch (RemoteException e) {
- String message = "Could not add the cartridge group: " + cartridgeGroupUuid;
- log.error(message, e);
- throw new RestAPIException(message, e);
- }
+ for (String cartridgeUuid : cartridgeTypes) {
+ cartridgeUuids[j] = cartridgeUuid;
+ j++;
}
-
// if any sub groups are specified in the group, they should be already deployed
if (serviceGroupDefinition.getGroups() != null) {
if (log.isDebugEnabled()) {
@@ -1405,8 +1392,9 @@ public class StratosApiV41Utils {
* @param groupBean groupBean
* @param cartridges List of cartridges
*/
- private static void findCartridgesInGroupBean(ServiceGroup groupBean, List<String> cartridges) {
-
+ private static void findCartridgesInGroupBean(ServiceGroup groupBean, List<String> cartridges) throws
+ RemoteException, CloudControllerServiceCartridgeNotFoundExceptionException {
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
if (groupBean == null || cartridges == null) {
return;
}
@@ -1414,7 +1402,9 @@ public class StratosApiV41Utils {
if (groupBean.getCartridges() != null) {
for (String cartridge : groupBean.getCartridges()) {
if (!cartridges.contains(cartridge)) {
- cartridges.add(cartridge);
+ Cartridge cartridge1 = CloudControllerServiceClient.getInstance().getCartridgeByTenant(cartridge,
+ groupBean.getTenantId());
+ cartridges.add(cartridge1.getUuid());
}
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/7dc73365/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
index 4749faa..a1f2c6a 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
@@ -123,9 +123,9 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
//Cluster active handling
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
- /* boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
RestConstants.CARTRIDGE_GROUPS_NAME);
- assertEquals(removedGroup, false); */
+ assertEquals(removedGroup, false);
boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -171,7 +171,7 @@ public class ApplicationBurstingTest extends StratosTestServerManager {
"cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
assertEquals(beanRemoved, null);
- boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
RestConstants.CARTRIDGE_GROUPS_NAME);
assertEquals(removedGroup, true);
http://git-wip-us.apache.org/repos/asf/stratos/blob/7dc73365/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
index 5f2919d..2fd4100 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
@@ -123,9 +123,9 @@ public class SingleClusterScalingTest extends StratosTestServerManager {
//Cluster active handling
TopologyHandler.getInstance().assertClusterActivation(bean.getApplicationId());
- /* boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
RestConstants.CARTRIDGE_GROUPS_NAME);
- assertEquals(removedGroup, false); */
+ assertEquals(removedGroup, false);
boolean removedAuto = restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
autoscalingPolicyId, RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -171,7 +171,7 @@ public class SingleClusterScalingTest extends StratosTestServerManager {
"cartridge-group-app", ApplicationBean.class, RestConstants.APPLICATIONS_NAME);
assertEquals(beanRemoved, null);
- boolean removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
+ removedGroup = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
RestConstants.CARTRIDGE_GROUPS_NAME);
assertEquals(removedGroup, true);
http://git-wip-us.apache.org/repos/asf/stratos/blob/7dc73365/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
index 8db4af8..4cd3235 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/group/CartridgeGroupTest.java
@@ -75,7 +75,7 @@ public class CartridgeGroupTest extends StratosTestServerManager {
assertEquals(String.format("Updated Cartridge Group didn't match: [cartridge-group-name] %s",
"g4-g5-g6"), updatedBean.getName(), "G4");
- /* boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
+ boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
RestConstants.CARTRIDGE_GROUPS_NAME);
assertEquals(String.format("Cartridge can be removed while it is used in " +
"cartridge group: [cartridge-name] %s", "c4"), removedC1, false);
@@ -90,7 +90,7 @@ public class CartridgeGroupTest extends StratosTestServerManager {
RestConstants.CARTRIDGE_GROUPS_NAME);
assertEquals(String.format("Cartridge can be removed while it is used in " +
"cartridge group: [cartridge-name] %s",
- "c6"), removedC3, false); */
+ "c6"), removedC3, false);
boolean removed = restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G4",
RestConstants.CARTRIDGE_GROUPS_NAME);
@@ -104,17 +104,17 @@ public class CartridgeGroupTest extends StratosTestServerManager {
"[cartridge-group-name] %s",
"g4-g5-g6"), beanRemoved, null);
- boolean removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
+ removedC1 = restClient.removeEntity(RestConstants.CARTRIDGES, "c4",
RestConstants.CARTRIDGE_GROUPS_NAME);
assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
"c4"), removedC1, true);
- boolean removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5",
+ removedC2 = restClient.removeEntity(RestConstants.CARTRIDGES, "c5",
RestConstants.CARTRIDGE_GROUPS_NAME);
assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
"c5"), removedC2, true);
- boolean removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6",
+ removedC3 = restClient.removeEntity(RestConstants.CARTRIDGES, "c6",
RestConstants.CARTRIDGE_GROUPS_NAME);
assertEquals(String.format("Cartridge can not be removed : [cartridge-name] %s",
"c6"), removedC3, true);