You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ud...@apache.org on 2013/12/16 15:18:48 UTC
[1/3] git commit: Adding Undeploy deployment policy and autoscaler
policy
Updated Branches:
refs/heads/master e98006b15 -> 533665ae3
Adding Undeploy deployment policy and autoscaler policy
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/08d597d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/08d597d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/08d597d7
Branch: refs/heads/master
Commit: 08d597d72270063ebee7ccb7044c5961598ef00a
Parents: 8bac94f
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Dec 16 15:59:31 2013 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Mon Dec 16 15:59:31 2013 -0500
----------------------------------------------------------------------
.../autoscaler/partition/PartitionManager.java | 24 +++++++++-
.../autoscaler/policy/PolicyManager.java | 9 +++-
.../autoscaler/registry/RegistryManager.java | 48 ++++++++++++++++++++
3 files changed, 79 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/08d597d7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java
index 55205a9..5b9c3ab 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java
@@ -132,7 +132,29 @@ private static final Log log = LogFactory.getLog(PartitionManager.class);
}
}
- public void addNetworkPartitionContext(NetworkPartitionContext ctxt) {
+ public void undeployNetworkPartitions(DeploymentPolicy depPolicy) {
+ for(PartitionGroup partitionGroup: depPolicy.getPartitionGroups()){
+ String id = partitionGroup.getId();
+ if (networkPartitionContexts.containsKey(id)) {
+ NetworkPartitionContext netPartCtx = this.getNetworkPartition(id);
+ // remove from information model
+ this.removeNetworkPartitionContext(netPartCtx);
+ //remove from the registry
+ RegistryManager.getInstance().removeNetworkPartition(this.getNetworkPartition(id).getId());
+ }else{
+ String errMsg = "Network partition context not found for policy " + depPolicy;
+ log.error(errMsg);
+ throw new AutoScalerException(errMsg);
+ }
+
+ }
+ }
+
+ private void removeNetworkPartitionContext(NetworkPartitionContext netPartCtx) {
+ networkPartitionContexts.remove(netPartCtx.getId());
+ }
+
+ public void addNetworkPartitionContext(NetworkPartitionContext ctxt) {
networkPartitionContexts.put(ctxt.getId(), ctxt);
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/08d597d7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
index 0c19d60..619f4bf 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
@@ -147,6 +147,7 @@ public class PolicyManager {
log.debug("Removing policy :" + policy);
}
autoscalePolicyListMap.remove(policy);
+ RegistryManager.getInstance().removeAutoscalerPolicy(this.getAutoscalePolicy(policy));
} else {
throw new InvalidPolicyException("No such policy [" + policy + "] exists");
}
@@ -194,8 +195,14 @@ public class PolicyManager {
public void removeDeploymentPolicy(String policy) throws InvalidPolicyException {
if (deploymentPolicyListMap.containsKey(policy)) {
if (log.isDebugEnabled()) {
- log.debug("Removing policy :" + policy);
+ log.debug("Removing deployment policy :" + policy);
}
+ DeploymentPolicy depPolicy = this.getDeploymentPolicy(policy);
+ // undeploy network partitions this deployment policy.
+ PartitionManager.getInstance().undeployNetworkPartitions(depPolicy);
+ // undeploy the deployment policy.
+ RegistryManager.getInstance().removeDeploymentPolicy(depPolicy);
+ // remove from the infromation model.
deploymentPolicyListMap.remove(policy);
} else {
throw new InvalidPolicyException("No such policy [" + policy + "] exists");
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/08d597d7/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index 7b05a4f..9a40c83 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -264,4 +264,52 @@ public class RegistryManager {
}
return depPolicyList;
}
+
+ public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
+ String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
+ this.delete(resourcePath);
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Autoscaler policy deleted from registry: [id] %s [name] %s [description] %s",
+ autoscalePolicy.getId(), autoscalePolicy.getDisplayName(), autoscalePolicy.getDescription()));
+ }
+
+ }
+
+ public void removeDeploymentPolicy(DeploymentPolicy depPolicy){
+ String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DEPLOYMENT_POLICY_RESOURCE;
+ this.delete(resourcePath);
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Deployment policy deleted from registry: [id] %s" ,
+ depPolicy.getId()));
+ }
+ }
+
+ public void removeNetworkPartition(String networkPartition){
+ String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.NETWORK_PARTITION_RESOURCE;
+ this.delete(resourcePath);
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Network partition deleted from registry: [id] %s" ,
+ networkPartition));
+ }
+ }
+
+
+ private void delete(String resourcePath) {
+ try {
+ registryService.beginTransaction();
+ registryService.delete(resourcePath);
+ registryService.commitTransaction();
+ } catch (RegistryException e) {
+ try {
+ registryService.rollbackTransaction();
+ } catch (RegistryException e1) {
+ if(log.isErrorEnabled()) {
+ log.error("Could not rollback transaction", e);
+ }
+ }
+ log.error("Could not delete resource at "+ resourcePath);
+ throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e);
+ }
+
+ }
}
[2/3] git commit: rename policy remove methods
Posted by ud...@apache.org.
rename policy remove methods
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/1c863d96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/1c863d96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/1c863d96
Branch: refs/heads/master
Commit: 1c863d9607502622ca6af4c9694fcb0a258291da
Parents: 08d597d
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Dec 16 19:45:16 2013 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Mon Dec 16 19:45:16 2013 -0500
----------------------------------------------------------------------
.../java/org/apache/stratos/autoscaler/policy/PolicyManager.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/1c863d96/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
index 619f4bf..b766383 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java
@@ -141,7 +141,7 @@ public class PolicyManager {
* @param policy
* @throws InvalidPolicyException
*/
- public void removeAutoscalePolicy(String policy) throws InvalidPolicyException {
+ public void undeployAutoscalePolicy(String policy) throws InvalidPolicyException {
if (autoscalePolicyListMap.containsKey(policy)) {
if (log.isDebugEnabled()) {
log.debug("Removing policy :" + policy);
@@ -192,7 +192,7 @@ public class PolicyManager {
* @param policy
* @throws InvalidPolicyException
*/
- public void removeDeploymentPolicy(String policy) throws InvalidPolicyException {
+ public void undeployDeploymentPolicy(String policy) throws InvalidPolicyException {
if (deploymentPolicyListMap.containsKey(policy)) {
if (log.isDebugEnabled()) {
log.debug("Removing deployment policy :" + policy);
[3/3] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-stratos
Posted by ud...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/533665ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/533665ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/533665ae
Branch: refs/heads/master
Commit: 533665ae3883c6d8416e96a3d3362a8cb995cd4f
Parents: 1c863d9 e98006b
Author: Udara Liyanage <ud...@wso2.com>
Authored: Mon Dec 16 19:46:49 2013 -0500
Committer: Udara Liyanage <ud...@wso2.com>
Committed: Mon Dec 16 19:46:49 2013 -0500
----------------------------------------------------------------------
.../controller/topology/TopologyManager.java | 67 ++++----------------
.../controller/util/CloudControllerUtil.java | 5 +-
.../stratos/messaging/domain/topology/Port.java | 5 ++
.../messaging/domain/topology/Service.java | 7 ++
.../messaging/domain/topology/Topology.java | 5 ++
5 files changed, 32 insertions(+), 57 deletions(-)
----------------------------------------------------------------------