You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2013/11/11 20:30:47 UTC

[1/2] git commit: reverted the 9aad5dc65beb242d07d7bc96c2a5960dd2fe25c9

Updated Branches:
  refs/heads/master 9aad5dc65 -> 0b644e1c6


reverted the 9aad5dc65beb242d07d7bc96c2a5960dd2fe25c9


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

Branch: refs/heads/master
Commit: b0537d4fc40874a6a3fb60fa3169433c875deb53
Parents: 23c88cd
Author: rekathiru <rt...@gmail.com>
Authored: Mon Nov 11 12:29:47 2013 -0700
Committer: rekathiru <rt...@gmail.com>
Committed: Mon Nov 11 12:29:47 2013 -0700

----------------------------------------------------------------------
 .../controller/deployers/CartridgeDeployer.java |  19 +-
 .../cloud/controller/iaases/AWSEC2Iaas.java     |   6 +-
 .../controller/iaases/OpenstackNovaIaas.java    |   7 +-
 .../cloud/controller/iaases/VCloudIaas.java     |  22 +--
 .../impl/CloudControllerServiceImpl.java        | 196 +++++++++----------
 .../interfaces/CloudControllerService.java      |  30 +--
 .../cloud/controller/interfaces/Iaas.java       |   2 +
 .../controller/topology/TopologyBuilder.java    |   2 +-
 .../stratos/cloud/controller/util/Host.java     |  31 ++-
 .../stratos/cloud/controller/util/Region.java   |  23 +--
 .../cloud/controller/util/ServiceContext.java   |  22 ++-
 .../stratos/cloud/controller/util/Zone.java     |  30 ++-
 12 files changed, 228 insertions(+), 162 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
index 7b2ebe2..376e44b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployers/CartridgeDeployer.java
@@ -26,12 +26,11 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.axiom.AxiomXpathParser;
 import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor;
-import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
 import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.interfaces.Iaas;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
-import org.apache.stratos.cloud.controller.util.Cartridge;
-import org.apache.stratos.cloud.controller.util.IaasProvider;
+import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
+import org.apache.stratos.cloud.controller.util.*;
 import org.wso2.carbon.utils.CarbonUtils;
 
 import java.io.File;
@@ -175,6 +174,20 @@ public class CartridgeDeployer extends AbstractDeployer{
 					Iaas iaas = (Iaas) Class.forName(iaasProvider.getClassName()).newInstance();
 					iaas.buildComputeServiceAndTemplate(iaasProvider);
 					iaasProvider.setIaas(iaas);
+                    if(iaasProvider.getListOfRegions() != null) {
+                        for(Region region : iaasProvider.getListOfRegions()) {
+                            iaas.buildComputeServiceAndTemplate(region);
+                            for(Zone zone : region.getListOfZones()) {
+                                zone.setComputeService(region.getComputeService());
+                                iaas.buildTemplate(zone);
+                                for(Host host: zone.getListOfHosts()) {
+                                    host.setComputeService(region.getComputeService());
+                                    iaas.buildTemplate(host);
+                                }
+                            }
+
+                        }
+                    }
 					
 				} catch (Exception e) {
 					rename();

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
index c944a65..9fafdd9 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java
@@ -62,7 +62,7 @@ public class AWSEC2Iaas extends Iaas {
 
 	}
 
-	private void buildTemplate(IaasProvider iaas) {
+	public void buildTemplate(IaasProvider iaas) {
 		if (iaas.getComputeService() == null) {
 			String msg = "Compute service is null for IaaS provider: "
 					+ iaas.getName();
@@ -76,6 +76,10 @@ public class AWSEC2Iaas extends Iaas {
 		// set image id specified
 		templateBuilder.imageId(iaas.getImage());
 
+        if(!(iaas instanceof IaasProvider)) {
+           templateBuilder.locationId(iaas.getType());
+        }
+
 		if (iaas.getProperty("instanceType") != null) {
 			// set instance type eg: m1.large
 			templateBuilder.hardwareId(iaas.getProperty("instanceType"));

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
index cffae13..8c4bdae 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java
@@ -64,7 +64,7 @@ public class OpenstackNovaIaas extends Iaas {
 
 	}
 
-	private void buildTemplate(IaasProvider iaas) {
+	public void buildTemplate(IaasProvider iaas) {
 		if (iaas.getComputeService() == null) {
 			throw new CloudControllerException(
 					"Compute service is null for IaaS provider: "
@@ -80,6 +80,9 @@ public class OpenstackNovaIaas extends Iaas {
 		TemplateBuilder templateBuilder = iaas.getComputeService()
 				.templateBuilder();
 		templateBuilder.imageId(iaas.getImage());
+        if(!(iaas instanceof IaasProvider)) {
+           templateBuilder.locationId(iaas.getType());
+        }
 
 		// to avoid creation of template objects in each and every time, we
 		// create all
@@ -139,7 +142,7 @@ public class OpenstackNovaIaas extends Iaas {
 		iaas.setTemplate(template);
 	}
 
-	@Override
+    @Override
 	public void setDynamicPayload(IaasProvider iaasInfo) {
 
 		if (iaasInfo.getTemplate() != null && iaasInfo.getPayload() != null) {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java
index 4496cce..18120b0 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java
@@ -18,25 +18,25 @@
  */
 package org.apache.stratos.cloud.controller.iaases;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import org.apache.stratos.cloud.controller.exception.CloudControllerException;
-import org.apache.stratos.cloud.controller.jcloud.ComputeServiceBuilderUtil;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.exception.CloudControllerException;
+import org.apache.stratos.cloud.controller.interfaces.Iaas;
+import org.apache.stratos.cloud.controller.jcloud.ComputeServiceBuilderUtil;
+import org.apache.stratos.cloud.controller.util.IaasProvider;
 import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
 import org.jclouds.compute.options.TemplateOptions;
 import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
 import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
-import org.apache.stratos.cloud.controller.interfaces.Iaas;
-import org.apache.stratos.cloud.controller.util.IaasProvider;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
 
 public class VCloudIaas extends Iaas {
 
@@ -53,7 +53,7 @@ public class VCloudIaas extends Iaas {
 
 	}
 
-	private void buildTemplate(IaasProvider iaas) {
+	public void buildTemplate(IaasProvider iaas) {
 		if (iaas.getComputeService() == null) {
 			String msg = "Compute service is null for IaaS provider: "
 					+ iaas.getName();

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index 293b0ec..d0f3866 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -35,6 +35,8 @@ import org.apache.stratos.cloud.controller.topology.TopologyBuilder;
 import org.apache.stratos.cloud.controller.topology.TopologyEventMessageDelegator;
 import org.apache.stratos.cloud.controller.util.*;
 import org.apache.stratos.cloud.controller.util.Properties;
+import org.apache.stratos.messaging.domain.topology.Partition;
+import org.apache.stratos.messaging.domain.topology.Scope;
 import org.jclouds.compute.ComputeService;
 import org.jclouds.compute.domain.ComputeMetadata;
 import org.jclouds.compute.domain.NodeMetadata;
@@ -266,13 +268,14 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 	}
 
     @Override()
-	public String startInstance(String clusterId, LocationScope locationScope) {
+	public String startInstance(String clusterId, Partition partition) {
 
-		ComputeService computeService;
-		Template template;
+		ComputeService computeService = null;
+		Template template = null;
 		String ip;
-        String cloud = locationScope.getCloud();
-        String region = locationScope.getRegion();
+        String partitionId = partition.getId();
+        Scope scope = partition.getScope();
+        String provider = partition.getProperty("provider");
 		final Lock lock = new ReentrantLock();
 
 
@@ -310,19 +313,13 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 
 		for (IaasProvider iaas : serviceCtxt.getCartridge().getIaases()) {
 
-            if(cloud == null) {
+            if(provider == null) {
                 String msg = "There's no IaaS provided for the cluster: "
 					+ clusterId + " to start an instance";
                 log.fatal(msg);
                 throw new CloudControllerException(msg);
             }
-
-            if(region == null) {
-                log.info("Region is not provided. Hence the default region is taken into the spawning a new instance");
-            }
-            //checking for the cloud and the region
-            //TODO adding more locations and retrieve it from the request received
-            if(iaas.getType().equals(cloud)) {
+            if(iaas.getType().equals(provider)) {
                 IaasContext ctxt;
                 if ((ctxt = serviceCtxt.getIaasContext(iaas.getType())) == null) {
                     ctxt = serviceCtxt.addIaasContext(iaas.getType());
@@ -338,12 +335,38 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 
                     iaas.getIaas().setDynamicPayload(iaas);
 
-                    // get the ComputeService
-                    computeService = iaas.getComputeService();
-                     // corresponding Template
-                    template = iaas.getTemplate();
-
-
+                    // get the pre built ComputeService from provider or region or zone or host
+                    if(scope.name().equals(Scope.PROVIDER.name())) {
+                        computeService = iaas.getComputeService();
+                        template = iaas.getTemplate();
+                    } else if(scope.name().equals(Scope.REGION.name())) {
+                        for(Region region : iaas.getListOfRegions()) {
+                            if(region.getId().equals(partitionId)) {
+                                computeService = region.getComputeService();
+                                template = region.getTemplate();
+                            }
+                        }
+                    } else if(scope.name().equals(Scope.ZONE.name())) {
+                        for(Region region : iaas.getListOfRegions()) {
+                            for(Zone zone : region.getListOfZones()) {
+                               if(zone.getId().equals(partitionId)) {
+                                computeService = zone.getComputeService();
+                                template = zone.getTemplate();
+                                }
+                            }
+                        }
+                    } else if(scope.name().equals(Scope.HOST.name())) {
+                        for(Region region : iaas.getListOfRegions()) {
+                            for(Zone zone : region.getListOfZones()) {
+                                for(Host host: zone.getListOfHosts()) {
+                                    if(host.getId().equals(partitionId)) {
+                                        computeService = host.getComputeService();
+                                        template = host.getTemplate();
+                                    }
+                                }
+                            }
+                        }
+                    }
                     if (template == null) {
                         String msg = "Failed to start an instance in "
                                 + iaas.getType()
@@ -440,7 +463,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 
                         // trigger topology
                         TopologyBuilder.handleMemberSpawned(memberID, serviceCtxt.getCartridgeType(), clusterId,
-                                 node.getId(), locationScope, privateIp);
+                                 node.getId(), partition, privateIp);
 
                         //update the topology with the newly spawned member
                         // publish data
@@ -471,20 +494,14 @@ public class CloudControllerServiceImpl implements CloudControllerService {
                                 e);
                     }
             }
-            else {
-                if(region != null) {
-                   log.error("Failed to start an instance, in any IaaS: " + cloud +
-                           " of the region: " + region +  "for the cluster: "
-				            + clusterId);
-                }
-            }
+
         }
         return null;
 
 	}
 
     @Override
-    public String startInstances(String clusterId, LocationScope locationScope, int noOfInstancesToBeSpawned) {
+    public String startInstances(String clusterId, Partition partition, int noOfInstancesToBeSpawned) {
         log.info("aaaaaaaaaaaaaaaaaaaaaaaa");
         //TODO
         return null;
@@ -549,10 +566,11 @@ public class CloudControllerServiceImpl implements CloudControllerService {
     }
 
 	@Override
-	public boolean terminateInstance(String clusterId, LocationScope locationScope) {
+	public boolean terminateInstance(String clusterId, Partition partition) {
 
-         String cloud = locationScope.getCloud();
-        String region = locationScope.getRegion();
+        String partitionId = partition.getId();
+        Scope scope = partition.getScope();
+        String provider = partition.getProperty("provider");
 		log.info("Starting to terminate an instance of domain : " + clusterId);
 
 		ServiceContext serviceCtxt = dataHolder
@@ -585,7 +603,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 					+ iaas.getType()
 					+ ". Hence, will try to terminate an instance in another IaaS if possible.";
             //TODO adding more locations and retrieve it from the request received
-            if(iaas.getType().equals(cloud)) {
+            if(iaas.getType().equals(provider)) {
                 String nodeId = null;
 
                 IaasContext ctxt = serviceCtxt.getIaasContext(iaas.getType());
@@ -609,7 +627,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
                 }
 
                 // terminate it!
-                terminate(iaas, ctxt, nodeId);
+                terminate(iaas, ctxt, nodeId, partition);
 
                 // log information
                 logTermination(nodeId, ctxt, serviceCtxt);
@@ -631,7 +649,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 	}
 
     @Override
-    public boolean terminateInstances(int noOfInstances, String clusterId, LocationScope locationScope) {
+    public boolean terminateInstances(int noOfInstances, String clusterId, Partition partition) {
         log.info("vvvvvvvvvvvvvvvvv");
         return false;  //TODO
     }
@@ -642,75 +660,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
         return false;  //TODO
     }
 
-    @Override
-	public boolean terminateLastlySpawnedInstance(String clusterId) {
-        log.info("Starting to terminate the last instance spawned, of domain : "
-				+ clusterId);
-
-		ServiceContext serviceCtxt = dataHolder
-				.getServiceContextFromDomain(clusterId);
-
-		if (serviceCtxt == null) {
-			String msg = "Not a registered service: domain - " + clusterId;
-			log.fatal(msg);
-			throw new CloudControllerException(msg);
-		}
-
-		// load Cartridge, if null
-		//if (serviceCtxt.getCartridge() == null) {
-			serviceCtxt.setCartridge(loadCartridge(
-					serviceCtxt.getCartridgeType(),
-					dataHolder.getCartridges()));
-		//}
-
-		if (serviceCtxt.getCartridge() == null) {
-			String msg = "There's no registered Cartridge found. Domain - "
-					+ clusterId;
-			log.fatal(msg);
-			throw new CloudControllerException(msg);
-		}
-
-		IaasProvider iaas = serviceCtxt.getCartridge().getLastlyUsedIaas();
-		// this is required since, we need to find the correct reference.
-		// caz if the lastly used iaas retrieved from registry, it is not a
-		// reference.
-		iaas = serviceCtxt.getCartridge().getIaasProvider(iaas.getType());
-
-		if (iaas != null) {
-
-			String nodeId = null;
-			IaasContext ctxt = serviceCtxt.getIaasContext(iaas.getType());
-
-			int i;
-			for (i = ctxt.getNodeIds().size() - 1; i >= 0; i--) {
-				String id = ctxt.getNodeIds().get(i);
-				if (id != null) {
-					nodeId = id;
-					break;
-				}
-			}
-
-			if (nodeId != null) {
-
-				// terminate it!
-				iaas = terminate(iaas, ctxt, nodeId);
-
-				// log information
-				logTermination(nodeId, ctxt, serviceCtxt);
-
-				return true;
-			}
-
-		}
-
-		log.info("Termination of an instance which is belong to domain '"
-				+ clusterId + ", failed! Reason: No matching "
-				+ "running instance found in lastly used IaaS.");
-
-		return false;
-
-	}
-
 	@Override
 	public boolean terminateAllInstances(String clusterId) {
 
@@ -756,7 +705,14 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 			for (String id : temp) {
 				if (id != null) {
 					// terminate it!
-					terminate(iaas, ctxt, id);
+                    //TODO need to enable once partition added to the topology
+                    /*Collection<Member> members = TopologyManager.getInstance().getTopology().
+                            getService(serviceCtxt.getCartridgeType()).
+                            getCluster(serviceCtxt.getClusterId()).getMembers();
+                    for (Iterator iterator = members.iterator(); iterator.hasNext();) {
+                         Member member = (Member) iterator.next();
+                         terminate(iaas, ctxt, member.getIaasNodeId(), member.getPartition());
+                    }*/
 
 					// log information
 					logTermination(id, ctxt, serviceCtxt);
@@ -857,8 +813,9 @@ public class CloudControllerServiceImpl implements CloudControllerService {
      * @return will return the IaaSProvider
      */
 	private IaasProvider terminate(IaasProvider iaasTemp, IaasContext ctxt,
-			String nodeId) {
-
+			String nodeId, Partition partition) {
+        Scope scope = partition.getScope();
+        String partitionId = partition.getId();
 		// this is just to be safe
 		if (iaasTemp.getComputeService() == null) {
 			String msg = "Unexpeced error occured! IaasContext's ComputeService is null!";
@@ -866,6 +823,33 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 			throw new CloudControllerException(msg);
 		}
 
+        if(scope.name().equals(Scope.PROVIDER.name())) {
+            iaasTemp.getComputeService().destroyNode(nodeId);
+        } else if(scope.name().equals(Scope.REGION.name())) {
+            for(Region region : iaasTemp.getListOfRegions()) {
+                if(region.getId().equals(partitionId)) {
+                    region.getComputeService();
+                }
+            }
+        } else if(scope.name().equals(Scope.ZONE.name())) {
+            for(Region region : iaasTemp.getListOfRegions()) {
+                for(Zone zone : region.getListOfZones()) {
+                   if(zone.getId().equals(partitionId)) {
+                        zone.getComputeService().destroyNode(nodeId);
+                   }
+                }
+            }
+        } else if(scope.name().equals(Scope.HOST.name())) {
+            for(Region region : iaasTemp.getListOfRegions()) {
+                for(Zone zone : region.getListOfZones()) {
+                    for(Host host: zone.getListOfHosts()) {
+                        if(host.getId().equals(partitionId)) {
+                            host.getComputeService().destroyNode(nodeId);
+                        }
+                    }
+                }
+            }
+        }
 		// destroy the node
 		iaasTemp.getComputeService().destroyNode(nodeId);
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
index 24428fc..a657d02 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
@@ -21,8 +21,8 @@ package org.apache.stratos.cloud.controller.interfaces;
 import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeException;
 import org.apache.stratos.cloud.controller.exception.UnregisteredServiceException;
 import org.apache.stratos.cloud.controller.util.CartridgeInfo;
-import org.apache.stratos.cloud.controller.util.LocationScope;
 import org.apache.stratos.cloud.controller.util.Properties;
+import org.apache.stratos.messaging.domain.topology.Partition;
 
 import java.util.List;
 
@@ -71,27 +71,27 @@ public interface CloudControllerService {
      * 
      * @param clusterId
      *            cluster ID of the instance to be started up.
-     * @param locationScope
+     * @param partition
      *            It contains the region, zone, network and host of a IaaS where
      *            an instance need to be started.
      * @return public IP which is associated with the newly started instance.
      */
-    public String startInstance(String clusterId, LocationScope locationScope);
+    public String startInstance(String clusterId, Partition partition);
 
     /**
      * Calling this method will spawn more than one ininstances in the
-      * specified locationScope for the particular cluster
+      * specified partition for the particular cluster
      *
      * @param clusterId
      *            cluster ID of the instance to be started up.
      * @param noOfInstancesToBeSpawned
      *            no of instances to be started up.
-     * @param locationScope
+     * @param partition
      *            It contains the region, zone, network and host of a IaaS where
      *            an instance need to be started.
      * @return public IP which is associated with the newly started instance.
      */
-    public String startInstances(String clusterId, LocationScope locationScope, int noOfInstancesToBeSpawned);
+    public String startInstances(String clusterId, Partition partition, int noOfInstancesToBeSpawned);
     
     /**
      * Calling this method will result in termination of an instance which is belong
@@ -99,12 +99,12 @@ public interface CloudControllerService {
      * 
      * @param clusterId
      *            cluster ID of the instance to be terminated.
-     * @param locationScope
+     * @param partition
      *            It contains the region, zone, network and host of a IaaS where
      *            an instance need to be terminated..
      * @return whether an instance terminated successfully or not.
      */
-    public boolean terminateInstance(String clusterId, LocationScope locationScope);
+    public boolean terminateInstance(String clusterId, Partition partition);
 
     /**
      * Calling this method will result in termination of an instance which is belong
@@ -114,12 +114,12 @@ public interface CloudControllerService {
      *            no of instances to be started up
      * @param clusterId
      *            cluster ID of the instance to be terminated.
-     * @param locationScope
+     * @param partition
      *            It contains the region, zone, network and host of a IaaS where
      *            an instance need to be terminated..
      * @return whether an instance terminated successfully or not.
      */
-    public boolean terminateInstances(int noOfInstances, String clusterId, LocationScope locationScope);
+    public boolean terminateInstances(int noOfInstances, String clusterId, Partition partition);
 
      /**
      * Calling this method will result in termination of an instance which is belong
@@ -141,17 +141,7 @@ public interface CloudControllerService {
      */
     public boolean terminateAllInstances(String clusterId);
 
-    
     /**
-     * Calling this method will result in termination of the lastly spawned instance which is
-     * belong to the provided clusterID.
-     * 
-     * @param clusterId
-     *            service domain of the instance to be terminated.
-     * @return whether the termination is successful or not.
-     */
-    public boolean terminateLastlySpawnedInstance(String clusterId);
-
     /**
      * Unregister the service cluster which represents by this domain and sub domain.
      * @param clusterId service cluster domain

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java
index 4883ca3..bf8b0c2 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java
@@ -70,5 +70,7 @@ public abstract class Iaas {
      * @return whether the key pair creation is successful or not.
      */
     public abstract boolean createKeyPairFromPublicKey(IaasProvider iaasInfo, String region, String keyPairName, String publicKey);
+
+    public abstract void buildTemplate(IaasProvider iaas);
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index cae793c..d03acbd 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -205,7 +205,7 @@ public class TopologyBuilder {
     }
 
     public static void handleMemberSpawned(String memberId, String serviceName, String clusterId,
-                                           String iaasNodeId, LocationScope locationScope, String privateIp) {
+                                           String iaasNodeId, Partition locationScope, String privateIp) {
         //adding the new member to the cluster after it is successfully started in IaaS.
         Topology topology = TopologyManager.getInstance().getTopology();
         Service service = topology.getService(serviceName);

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Host.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Host.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Host.java
index 6a001d6..8271042 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Host.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Host.java
@@ -1,13 +1,20 @@
 package org.apache.stratos.cloud.controller.util;
 
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.Template;
+
 import java.util.HashMap;
 import java.util.Map;
 
-public class Host {
+public class Host extends Zone {
     private String id;
     private String type;
     private Map<String, String> properties = new HashMap<String, String>();
 
+    private transient ComputeService computeService;
+
+    private transient Template template;
+
 
     public String getId() {
         return id;
@@ -41,6 +48,26 @@ public class Host {
     }
 
     public String getProperty(String key) {
-        return getProperties().get(key);
+        if(getProperties().get(key) != null) {
+            return getProperties().get(key);
+        } else {
+            return super.getProperty(key);
+        }
+    }
+
+     public ComputeService getComputeService() {
+        return computeService;
+    }
+
+    public void setComputeService(ComputeService computeService) {
+        this.computeService = computeService;
+    }
+
+    public Template getTemplate() {
+        return template;
+    }
+
+    public void setTemplate(Template template) {
+        this.template = template;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Region.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Region.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Region.java
index 7606e2a..561285a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Region.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Region.java
@@ -7,9 +7,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-public class Region {
+public class Region extends IaasProvider {
     private String imageId;
-    private String provider;
     private String identity;
     private String credential;
     private String id;
@@ -23,7 +22,11 @@ public class Region {
     private Map<String, String> properties = new HashMap<String, String>();
 
     public String getProperty(String key) {
-        return getProperties().get(key);
+        if(getProperties().get(key) != null) {
+            return getProperties().get(key);
+        } else {
+            return super.getProperty(key);
+        }
     }
 
     public Map<String, String> getProperties() {
@@ -50,15 +53,10 @@ public class Region {
         this.imageId = imageId;
     }
 
-    public String getProvider() {
-        return provider;
-    }
-
-    public void setProvider(String provider) {
-        this.provider = provider;
-    }
-
     public String getIdentity() {
+        if(identity == null) {
+            return super.getIdentity();
+        }
         return identity;
     }
 
@@ -67,6 +65,9 @@ public class Region {
     }
 
     public String getCredential() {
+        if(credential == null) {
+            return super.getCredential();
+        }
         return credential;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ServiceContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ServiceContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ServiceContext.java
index b60a2c1..887ca15 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ServiceContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/ServiceContext.java
@@ -22,12 +22,11 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.exception.CloudControllerException;
+import org.apache.stratos.messaging.domain.topology.Partition;
 import org.wso2.carbon.utils.CarbonUtils;
 
 import java.io.*;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.*;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
@@ -48,6 +47,7 @@ public class ServiceContext implements Serializable{
     private Cartridge cartridge;
     private StringBuilder payload;
     private String autoScalerPolicyName;
+    private List<Partition> partitionList = new ArrayList<Partition>();
 
     /**
      * Key - Value pair.
@@ -363,4 +363,20 @@ public class ServiceContext implements Serializable{
     public void setAutoScalerPolicyName(String autoScalerPolicyName) {
         this.autoScalerPolicyName = autoScalerPolicyName;
     }
+
+    public List<Partition> getPartitionList() {
+        return partitionList;
+    }
+
+    public void setPartitionList(List<Partition> partitionList) {
+        this.partitionList = partitionList;
+    }
+
+    public void addPartition(Partition partition) {
+        this.partitionList.add(partition);
+    }
+
+    public void removePartition(Partition partition) {
+        this.partitionList.remove(partition);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/b0537d4f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Zone.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Zone.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Zone.java
index 168629d..9ac8826 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Zone.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Zone.java
@@ -1,15 +1,21 @@
 package org.apache.stratos.cloud.controller.util;
 
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.Template;
+
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-public class Zone {
+public class Zone extends Region {
     private String id;
     private String type;
     private List<Host> listOfHosts;
 
     private Map<String, String> properties = new HashMap<String, String>();
+    private transient ComputeService computeService;
+
+    private transient Template template;
 
     public String getId() {
         return id;
@@ -43,7 +49,11 @@ public class Zone {
     }
 
     public String getProperty(String key) {
-        return getProperties().get(key);
+        if(getProperties().get(key) != null) {
+            return getProperties().get(key);
+        } else {
+            return super.getProperty(key);
+        }
     }
 
     public List<Host> getListOfHosts() {
@@ -61,4 +71,20 @@ public class Zone {
     public void removeHost(Host host) {
         this.listOfHosts.remove(host);
     }
+
+     public ComputeService getComputeService() {
+        return computeService;
+    }
+
+    public void setComputeService(ComputeService computeService) {
+        this.computeService = computeService;
+    }
+
+    public Template getTemplate() {
+        return template;
+    }
+
+    public void setTemplate(Template template) {
+        this.template = template;
+    }
 }


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos

Posted by re...@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/0b644e1c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/0b644e1c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/0b644e1c

Branch: refs/heads/master
Commit: 0b644e1c6e8d52b1c09adf4e9c56ff9bf7c95665
Parents: b0537d4 9aad5dc
Author: rekathiru <rt...@gmail.com>
Authored: Mon Nov 11 12:30:14 2013 -0700
Committer: rekathiru <rt...@gmail.com>
Committed: Mon Nov 11 12:30:14 2013 -0700

----------------------------------------------------------------------

----------------------------------------------------------------------