Updated Branches:
  refs/heads/master 85abff74d -> 5ec222424

Partition update in registry


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

Branch: refs/heads/master
Commit: f7c9b9cb21727143e16394ac88b291d5e156650c
Parents: ea115ab
Author: Udara Liyanage <[email protected]>
Authored: Sat Dec 7 17:05:50 2013 -0500
Committer: Udara Liyanage <[email protected]>
Committed: Sat Dec 7 17:05:50 2013 -0500

----------------------------------------------------------------------
 .../autoscaler/partition/PartitionManager.java  | 22 ++++++++++++++++----
 .../autoscaler/registry/RegistryManager.java    |  3 ++-
 2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f7c9b9cb/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 52fd8f7..c86176e 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
@@ -24,7 +24,6 @@ import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import 
org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
 import org.apache.stratos.autoscaler.exception.PartitionValidationException;
 import org.apache.stratos.autoscaler.registry.RegistryManager;
@@ -44,6 +43,9 @@ private static final Log log = 
LogFactory.getLog(PartitionManager.class);
        
        private static PartitionManager instance;
        
+       String partitionResourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE 
+                       + AutoScalerConstants.PARTITION_RESOURCE + "/";
+       
        private PartitionManager(){}
        
        public static PartitionManager getInstance(){
@@ -62,8 +64,7 @@ private static final Log log = 
LogFactory.getLog(PartitionManager.class);
                if(this.partitionExist(partition.getId()))
                        throw new AutoScalerException("A parition with the ID " 
+  partitionId + " already exist.");
                                
-               String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE 
-                       + AutoScalerConstants.PARTITION_RESOURCE + "/" + 
partition.getId();
+               String resourcePath= this.partitionResourcePath + 
partition.getId();
                
         RegistryManager regManager = RegistryManager.getInstance();     
         
@@ -81,6 +82,8 @@ private static final Log log = 
LogFactory.getLog(PartitionManager.class);
                return true;
        }
        
+       
+       
        public Partition getPartitionById(String partitionId){
                if(partitionExist(partitionId))
                        return partitionListMap.get(partitionId);
@@ -95,7 +98,18 @@ private static final Log log = 
LogFactory.getLog(PartitionManager.class);
        }
        
        public boolean validatePartition(Partition partition) throws 
PartitionValidationException{
-               return 
CloudControllerClient.getInstance().validatePartition(partition);
+               return true;
+               //return 
CloudControllerClient.getInstance().validatePartition(partition);
+       }
+
+       public void updatePartition(Partition newPartition,Partition 
oldPartition) throws RegistryException {
+               if(!oldPartition.getId().equals(newPartition.getId()))
+                       throw new AutoScalerException("Can not update.Id s of 
the two partitions did not match.");
+               
+               oldPartition=newPartition;
+               //overwrite the registry resource.
+               RegistryManager.getInstance().persist(
+                               newPartition, this.partitionResourcePath + 
newPartition.getId());
        }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/f7c9b9cb/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 4322e7a..791e4da 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
@@ -56,9 +56,10 @@ public class RegistryManager {
     public void persist(Object dataObj, String resourcePath) throws 
RegistryException {
        
         try {
+               /*
                if (registryService.resourceExists(resourcePath)) {
                 throw new AutoScalerException("Resource already exist in the 
registry: " + resourcePath);
-            }
+            }*/
             registryService.beginTransaction();
 
             Resource nodeResource = registryService.newResource();

Reply via email to