stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [04/12] stratos git commit: Renaming iaas classes and moving them to new packages
Date Wed, 24 Dec 2014 17:36:27 GMT
http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
new file mode 100644
index 0000000..a55048c
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
@@ -0,0 +1,625 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.iaases.kubernetes;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.concurrent.ScheduledThreadExecutor;
+import org.apache.stratos.cloud.controller.context.CloudControllerContext;
+import org.apache.stratos.cloud.controller.domain.*;
+import org.apache.stratos.cloud.controller.domain.Cartridge;
+import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesClusterContext;
+import org.apache.stratos.cloud.controller.exception.*;
+import org.apache.stratos.cloud.controller.iaases.Iaas;
+import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
+import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceUtil;
+import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.cloud.controller.util.PodActivationWatcher;
+import org.apache.stratos.common.beans.NameValuePair;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesCluster;
+import org.apache.stratos.cloud.controller.domain.kubernetes.PortRange;
+import org.apache.stratos.kubernetes.client.KubernetesApiClient;
+import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException;
+import org.apache.stratos.kubernetes.client.model.*;
+import org.apache.stratos.kubernetes.client.model.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * Kubernetes IaaS implementation.
+ */
+public class KubernetesIaas extends Iaas {
+
+    private static final Log log = LogFactory.getLog(KubernetesIaas.class);
+
+    private static final long POD_CREATION_TIMEOUT = 120000; // 2 min
+    private static final String PAYLOAD_PARAMETER_SEPARATOR = ",";
+    private static final String PAYLOAD_PARAMETER_NAME_VALUE_SEPARATOR = "=";
+
+    private PartitionValidator partitionValidator;
+    private List<NameValuePair> payload;
+
+    public KubernetesIaas(IaasProvider iaasProvider) {
+        super(iaasProvider);
+        partitionValidator = new KubernetesPartitionValidator();
+        payload = new ArrayList<NameValuePair>();
+    }
+
+    @Override
+    public void initialize() {
+    }
+
+    /**
+     * Set dynamic payload which needs to be passed to the containers as environment variables.
+     * @param payloadByteArray
+     */
+    @Override
+    public void setDynamicPayload(byte[] payloadByteArray) {
+        // Clear existing payload parameters
+        payload.clear();
+
+        if(payloadByteArray != null) {
+            String payloadString = new String(payloadByteArray);
+            String[] parameterArray = payloadString.split(PAYLOAD_PARAMETER_SEPARATOR);
+            if(parameterArray != null) {
+                for(String parameter : parameterArray) {
+                    if(parameter != null) {
+                        String[] nameValueArray = parameter.split(PAYLOAD_PARAMETER_NAME_VALUE_SEPARATOR);
+                        if ((nameValueArray != null) && (nameValueArray.length == 2)) {
+                            NameValuePair nameValuePair = new NameValuePair(nameValueArray[0], nameValueArray[1]);
+                            payload.add(nameValuePair);
+                        }
+                    }
+                }
+                if(log.isDebugEnabled()) {
+                    log.debug("Dynamic payload is set: " + payload.toString());
+                }
+            }
+        }
+    }
+
+    @Override
+    public MemberContext startInstance(MemberContext memberContext) throws CartridgeNotFoundException {
+        return startContainer(memberContext);
+    }
+
+    @Override
+    public PartitionValidator getPartitionValidator() {
+        return partitionValidator;
+    }
+
+    @Override
+    public void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException,
+            InvalidMemberException, MemberTerminationFailedException {
+        terminateContainer(memberContext.getMemberId());
+    }
+
+    /**
+     * Starts a container via kubernetes for the given member context.
+     * @param memberContext
+     * @return
+     * @throws CartridgeNotFoundException
+     */
+    public MemberContext startContainer(MemberContext memberContext)
+            throws CartridgeNotFoundException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireMemberContextWriteLock();
+
+            handleNullObject(memberContext, "Could not start container, member context is null");
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Starting container: [cartridge-type] %s", memberContext.getCartridgeType()));
+            }
+
+            // Validate cluster id
+            String clusterId = memberContext.getClusterId();
+            String memberId = memberContext.getMemberId();
+            handleNullObject(clusterId, "Could not start container, cluster id is null in member context");
+
+            // Validate cluster context
+            ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
+            handleNullObject(clusterContext, "Could not start container, cluster context not found: [cluster-id] "
+                    + clusterId + " [member-id] " + memberId);
+
+            // Validate partition
+            Partition partition = memberContext.getPartition();
+            handleNullObject(partition, "Could not start container, partition not found in member context: " +
+                    "[cluster-id] " + clusterId + " [member-id] " + memberId);
+
+            // Validate cartridge
+            String cartridgeType = clusterContext.getCartridgeType();
+            Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeType);
+            if (cartridge == null) {
+                String msg = "Could not start container, cartridge not found: [cartridge-type] " + cartridgeType + " " +
+                        "[cluster-id] " + clusterId + " [member-id] " + memberId;
+                log.error(msg);
+                throw new CartridgeNotFoundException(msg);
+            }
+
+            try {
+                String kubernetesClusterId = partition.getKubernetesClusterId();
+                KubernetesCluster kubernetesCluster = CloudControllerContext.getInstance().
+                        getKubernetesCluster(kubernetesClusterId);
+                handleNullObject(kubernetesCluster, "Could not start container, kubernetes cluster not found: " +
+                        "[kubernetes-cluster-id] " + kubernetesClusterId + " [cluster-id] " + clusterId +
+                        " [member-id] " + memberId);
+
+                // Prepare kubernetes context
+                String kubernetesMasterIp = kubernetesCluster.getKubernetesMaster().getHostIpAddress();
+                PortRange kubernetesPortRange = kubernetesCluster.getPortRange();
+                String kubernetesMasterPort = CloudControllerUtil.getProperty(
+                        kubernetesCluster.getKubernetesMaster().getProperties(), StratosConstants.KUBERNETES_MASTER_PORT,
+                        StratosConstants.KUBERNETES_MASTER_DEFAULT_PORT);
+
+                KubernetesClusterContext kubClusterContext = getKubernetesClusterContext(kubernetesClusterId,
+                        kubernetesMasterIp, kubernetesMasterPort, kubernetesPortRange.getUpper(),
+                        kubernetesPortRange.getLower());
+
+                // Get kubernetes API
+                KubernetesApiClient kubernetesApi = kubClusterContext.getKubApi();
+
+                // Create replication controller
+                createReplicationController(clusterContext, memberContext, kubernetesApi);
+
+                // Create proxy services for port mappings
+                List<Service> services = createProxyServices(clusterContext, kubClusterContext, kubernetesApi);
+                clusterContext.setKubernetesServices(services);
+                CloudControllerContext.getInstance().updateClusterContext(clusterContext);
+
+                // Wait for pod to be created
+                List<Pod> pods = waitForPodToBeCreated(memberContext, kubernetesApi);
+                if (pods.size() != 1) {
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("Pod did not create within %d sec, hence deleting the service: " +
+                                "[cluster-id] %s [member-id] %s", ((int)POD_CREATION_TIMEOUT/1000), clusterId, memberId));
+                    }
+                    try {
+                        terminateContainers(clusterId);
+                    } catch (Exception e) {
+                        String message = "Could not terminate containers which were partially created";
+                        log.error(message, e);
+                        throw new RuntimeException(message, e);
+                    }
+                }
+                Pod pod = pods.get(0);
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Pod created: [cluster-id] %s [member-id] %s [pod-id] %s",
+                            clusterId, memberId, pod.getId()));
+                }
+
+                // Create member context
+                MemberContext newMemberContext = createNewMemberContext(memberContext, pod);
+                CloudControllerContext.getInstance().addMemberContext(newMemberContext);
+
+                // wait till pod status turns to running and send member spawned.
+                ScheduledThreadExecutor exec = ScheduledThreadExecutor.getInstance();
+                if (log.isDebugEnabled()) {
+                    log.debug("Cloud Controller is starting the instance start up thread.");
+                }
+                CloudControllerContext.getInstance().addScheduledFutureJob(newMemberContext.getMemberId(),
+                        exec.schedule(new PodActivationWatcher(pod.getId(), newMemberContext, kubernetesApi), 5000));
+
+                // persist in registry
+                CloudControllerContext.getInstance().persist();
+                log.info("Container started successfully: [cluster-id] " + clusterId + " [member-id] " +
+                        memberContext.getMemberId());
+
+                return newMemberContext;
+            } catch (Exception e) {
+                String msg = String.format("Could not start container: [cartridge-type] %s [member-id] %s",
+                        memberContext.getCartridgeType(), memberContext.getMemberId());
+                log.error(msg, e);
+                throw new IllegalStateException(msg, e);
+            }
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    private MemberContext createNewMemberContext(MemberContext memberContext, Pod pod) {
+        MemberContext newMemberContext = new MemberContext();
+        newMemberContext.setCartridgeType(memberContext.getCartridgeType());
+        newMemberContext.setClusterId(memberContext.getClusterId());
+        newMemberContext.setClusterInstanceId(memberContext.getClusterInstanceId());
+        newMemberContext.setMemberId(memberContext.getMemberId());
+        newMemberContext.setNetworkPartitionId(memberContext.getNetworkPartitionId());
+        newMemberContext.setPartition(memberContext.getPartition());
+        newMemberContext.setInstanceId(pod.getId());
+        newMemberContext.setDefaultPrivateIP(pod.getCurrentState().getHostIP());
+        newMemberContext.setPrivateIPs(new String[]{pod.getCurrentState().getHostIP()});
+        newMemberContext.setDefaultPublicIP(pod.getCurrentState().getHostIP());
+        newMemberContext.setPublicIPs(new String[]{pod.getCurrentState().getHostIP()});
+        newMemberContext.setInitTime(memberContext.getInitTime());
+        newMemberContext.setProperties(memberContext.getProperties());
+        return newMemberContext;
+    }
+
+    private List<Pod> waitForPodToBeCreated(MemberContext memberContext, KubernetesApiClient kubernetesApi) throws KubernetesClientException, InterruptedException {
+        Labels labels = new Labels();
+        labels.setName(memberContext.getClusterId());
+        List<Pod> podList = new ArrayList<Pod>();
+        long startTime = System.currentTimeMillis();
+        while (podList.size() == 0) {
+            List<Pod> pods = kubernetesApi.queryPods(new Labels[]{labels});
+            if((pods != null) && (pods.size() > 0)){
+                for(Pod pod : pods) {
+                    if(pod != null) {
+                        podList.add(pod);
+                    }
+                }
+            }
+            if (log.isDebugEnabled()) {
+                log.debug("Member pod: [member-id] " + memberContext.getMemberId() + " [count] " + podList.size());
+            }
+            if ((System.currentTimeMillis() - startTime) > POD_CREATION_TIMEOUT) {
+                break;
+            }
+            Thread.sleep(5000);
+        }
+        return podList;
+    }
+
+    /**
+     * Create new replication controller for the cluster and generate environment variables using member context.
+     * @param memberContext
+     * @param kubernetesApi
+     * @throws KubernetesClientException
+     */
+    private void createReplicationController(ClusterContext clusterContext, MemberContext memberContext,
+                                                              KubernetesApiClient kubernetesApi)
+            throws KubernetesClientException {
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Creating replication controller: [cartridge-type] %s [member-id] %s",
+                    memberContext.getCartridgeType(), memberContext.getClusterId()));
+        }
+
+        Partition partition = memberContext.getPartition();
+        if (partition == null) {
+            String message = "Partition not found in member context: [member-id] " + memberContext.getMemberId();
+            log.error(message);
+            throw new RuntimeException(message);
+        }
+
+        Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(memberContext.getCartridgeType());
+        if (cartridge == null) {
+            String message = "Could not find cartridge: [cartridge-type] " + memberContext.getCartridgeType();
+            log.error(message);
+            throw new RuntimeException(message);
+        }
+
+        IaasProvider iaasProvider = cartridge.getIaasProviderOfPartition(partition.getId());
+        if (iaasProvider == null) {
+            String message = "Could not find iaas provider: [partition-id] " + partition.getId();
+            log.error(message);
+            throw new RuntimeException(message);
+        }
+
+        // Add dynamic payload to the member context
+        memberContext.setDynamicPayload(payload);
+
+        // Create replication controller
+        String replicationControllerId = memberContext.getMemberId();
+        String replicationControllerName = memberContext.getMemberId();
+        String dockerImage = iaasProvider.getImage();
+        List<Integer> containerPorts = KubernetesIaasUtil.prepareCartridgePorts(cartridge);
+        EnvironmentVariable[] environmentVariables = KubernetesIaasUtil.prepareEnvironmentVariables(
+                clusterContext, memberContext);
+        int replicas = 1;
+
+        kubernetesApi.createReplicationController(replicationControllerId, replicationControllerName,
+                dockerImage, containerPorts, environmentVariables, replicas);
+        if (log.isInfoEnabled()) {
+            log.info(String.format("Replication controller created successfully: [cartridge-type] %s [member-id] %s",
+                    memberContext.getCartridgeType(), memberContext.getClusterId()));
+        }
+    }
+
+    /**
+     * Create proxy services for the cluster and add them to the cluster context.
+     * @param clusterContext
+     * @param kubernetesClusterContext
+     * @param kubernetesApi
+     * @return
+     * @throws KubernetesClientException
+     */
+    private List<Service> createProxyServices(ClusterContext clusterContext,
+                                              KubernetesClusterContext kubernetesClusterContext,
+                                              KubernetesApiClient kubernetesApi) throws KubernetesClientException {
+        List<Service> services = new ArrayList<Service>();
+
+        String clusterId = clusterContext.getClusterId();
+        Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(clusterContext.getCartridgeType());
+        if(cartridge == null) {
+            String message = "Could not create kubernetes services, cartridge not found: [cartridge-type] " +
+                    clusterContext.getCartridgeType();
+            log.error(message);
+            throw new RuntimeException(message);
+        }
+
+        List<PortMapping> portMappings = cartridge.getPortMappings();
+        for(PortMapping portMapping : portMappings) {
+            String serviceId = KubernetesIaasUtil.prepareKubernetesServiceId(clusterId, portMapping);
+            int nextServicePort = kubernetesClusterContext.getNextServicePort();
+            if(nextServicePort == -1) {
+                throw new RuntimeException(String.format("Could not generate service port: [cluster-id] %s ",
+                        clusterContext.getClusterId()));
+            }
+
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Creating kubernetes service: [cluster-id] %s [service-id] %s " +
+                                "[protocol] %s [service-port] %d [container-port] %s [proxy-port] %s", clusterId,
+                        serviceId, portMapping.getProtocol(), nextServicePort, portMapping.getPort(),
+                        portMapping.getProxyPort()));
+            }
+
+            String serviceName = serviceId;
+            int servicePort = nextServicePort;
+            int containerPort = Integer.parseInt(portMapping.getPort());
+            String publicIp = kubernetesClusterContext.getMasterIp();
+
+            kubernetesApi.createService(serviceId, serviceName, servicePort, containerPort, publicIp);
+
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException ignore) {
+            }
+
+            Service service = kubernetesApi.getService(serviceId);
+            services.add(service);
+
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Kubernetes service successfully created: [cluster-id] %s [service-id] %s " +
+                                "[protocol] %s [service-port] %d [container-port] %s [proxy-port] %s", clusterId,
+                        service.getId(), portMapping.getProtocol(), service.getPort(), portMapping.getPort(),
+                        portMapping.getProxyPort()));
+            }
+        }
+        return services;
+    }
+
+    /**
+     * Terminate all the containers belong to a cluster by cluster id.
+     * @param clusterId
+     * @return
+     * @throws InvalidClusterException
+     */
+    public MemberContext[] terminateContainers(String clusterId)
+            throws InvalidClusterException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireMemberContextWriteLock();
+
+            ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
+            handleNullObject(clusterContext, "Could not terminate containers, cluster not found: [cluster-id] " + clusterId);
+
+            String kubernetesClusterId = CloudControllerUtil.getProperty(clusterContext.getProperties(),
+                    StratosConstants.KUBERNETES_CLUSTER_ID);
+            handleNullObject(kubernetesClusterId, "Could not terminate containers, kubernetes cluster id not found: " +
+                    "[cluster-id] " + clusterId);
+
+            KubernetesClusterContext kubClusterContext = CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
+            handleNullObject(kubClusterContext, "Could not terminate containers, kubernetes cluster not found: " +
+                    "[kubernetes-cluster-id] " + kubernetesClusterId);
+
+            KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+
+            // Remove the services
+            List<Service> services = clusterContext.getKubernetesServices();
+            if (services != null) {
+                for (Service service : services) {
+                    try {
+                        kubApi.deleteService(service.getId());
+                        int allocatedPort = service.getPort();
+                        kubClusterContext.deallocatePort(allocatedPort);
+                    } catch (KubernetesClientException e) {
+                        log.error("Could not remove kubernetes service: [cluster-id] " + clusterId, e);
+                    }
+                }
+            }
+
+            List<MemberContext> memberContextsRemoved = new ArrayList<MemberContext>();
+            List<MemberContext> memberContexts = CloudControllerContext.getInstance().getMemberContextsOfClusterId(clusterId);
+            for(MemberContext memberContext : memberContexts) {
+                try {
+                    MemberContext memberContextRemoved = terminateContainer(memberContext.getMemberId());
+                    memberContextsRemoved.add(memberContextRemoved);
+                } catch (MemberTerminationFailedException e) {
+                    String message = "Could not terminate container: [member-id] " + memberContext.getMemberId();
+                    log.error(message);
+                }
+            }
+
+            // persist
+            CloudControllerContext.getInstance().persist();
+            return memberContextsRemoved.toArray(new MemberContext[memberContextsRemoved.size()]);
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    /**
+     * Terminate a container by member id
+     * @param memberId
+     * @return
+     * @throws MemberTerminationFailedException
+     */
+    public MemberContext terminateContainer(String memberId) throws MemberTerminationFailedException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireMemberContextWriteLock();
+            handleNullObject(memberId, "Could not terminate container, member id is null");
+
+            MemberContext memberContext = CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
+            handleNullObject(memberContext, "Could not terminate container, member context not found: [member-id] " + memberId);
+
+            String clusterId = memberContext.getClusterId();
+            handleNullObject(clusterId, "Could not terminate container, cluster id is null: [member-id] " + memberId);
+
+            ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
+            handleNullObject(clusterContext, String.format("Could not terminate container, cluster context not found: " +
+                    "[cluster-id] %s [member-id] %s", clusterId, memberId));
+
+            String kubernetesClusterId = CloudControllerUtil.getProperty(clusterContext.getProperties(),
+                    StratosConstants.KUBERNETES_CLUSTER_ID);
+            handleNullObject(kubernetesClusterId, String.format("Could not terminate container, kubernetes cluster " +
+                    "context id is null: [cluster-id] %s [member-id] %s", clusterId, memberId));
+
+            KubernetesClusterContext kubernetesClusterContext = CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
+            handleNullObject(kubernetesClusterContext, String.format("Could not terminate container, kubernetes cluster " +
+                    "context not found: [cluster-id] %s [member-id] %s", clusterId, memberId));
+            KubernetesApiClient kubApi = kubernetesClusterContext.getKubApi();
+
+            // Remove the pod forcefully
+            try {
+                Labels l = new Labels();
+                l.setName(memberId);
+                // execute the label query
+                List<Pod> pods = kubApi.queryPods(new Labels[]{l});
+                for (Pod pod : pods) {
+                    try {
+                        // delete pods forcefully
+                        kubApi.deletePod(pod.getId());
+                    } catch (KubernetesClientException ignore) {
+                        // we can't do nothing here
+                        log.warn(String.format("Could not delete pod: [pod-id] %s", pod.getId()));
+                    }
+                }
+            } catch (KubernetesClientException e) {
+                // we're not going to throw this error, but proceed with other deletions
+                log.error("Could not delete pods of cluster: [cluster-id] " + clusterId, e);
+            }
+
+            // Remove the replication controller
+            try {
+                kubApi.deleteReplicationController(memberContext.getMemberId());
+                MemberContext memberToBeRemoved = CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
+                CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberToBeRemoved);
+                return memberToBeRemoved;
+            } catch (KubernetesClientException e) {
+                String msg = String.format("Failed to terminate member: [cluster-id] %s [member-id] %s", clusterId, memberId);
+                log.error(msg, e);
+                throw new MemberTerminationFailedException(msg, e);
+            }
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    /**
+     * Get kubernetes cluster context
+     * @param kubernetesClusterId
+     * @param kubernetesMasterIp
+     * @param kubernetesMasterPort
+     * @param upperPort
+     * @param lowerPort
+     * @return
+     */
+    private KubernetesClusterContext getKubernetesClusterContext(String kubernetesClusterId, String kubernetesMasterIp,
+                                                                 String kubernetesMasterPort, int upperPort, int lowerPort) {
+
+        KubernetesClusterContext kubernetesClusterContext = CloudControllerContext.getInstance().
+                getKubernetesClusterContext(kubernetesClusterId);
+        if (kubernetesClusterContext != null) {
+            return kubernetesClusterContext;
+        }
+
+        kubernetesClusterContext = new KubernetesClusterContext(kubernetesClusterId, kubernetesMasterIp,
+                kubernetesMasterPort, lowerPort, upperPort);
+        CloudControllerContext.getInstance().addKubernetesClusterContext(kubernetesClusterContext);
+        return kubernetesClusterContext;
+    }
+
+    private String readProperty(String property, org.apache.stratos.common.Properties properties, String object) {
+        String propVal = CloudControllerUtil.getProperty(properties, property);
+        handleNullObject(propVal, "Property validation failed. Could not find property: '" + property + " in " + object);
+        return propVal;
+
+    }
+
+    private void handleNullObject(Object obj, String errorMsg) {
+        if (obj == null) {
+            log.error(errorMsg);
+            throw new IllegalArgumentException(errorMsg);
+        }
+    }
+
+    @Override
+    public void releaseAddress(String ip) {
+
+    }
+
+    @Override
+    public boolean isValidRegion(String region) throws InvalidRegionException {
+        // No regions in kubernetes cluster
+        return true;
+    }
+
+    @Override
+    public boolean isValidZone(String region, String zone) throws InvalidZoneException, InvalidRegionException {
+        // No zones in kubernetes cluster
+        return true;
+    }
+
+    @Override
+    public boolean isValidHost(String zone, String host) throws InvalidHostException {
+        // No zones in kubernetes cluster
+        return true;
+    }
+
+    @Override
+    public String createVolume(int sizeGB, String snapshotId) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String attachVolume(String instanceId, String volumeId, String deviceName) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void detachVolume(String instanceId, String volumeId) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void deleteVolume(String volumeId) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String getIaasDevice(String device) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition) {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
new file mode 100644
index 0000000..6d2ad4f
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.iaases.kubernetes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.domain.Cartridge;
+import org.apache.stratos.cloud.controller.domain.ClusterContext;
+import org.apache.stratos.cloud.controller.domain.MemberContext;
+import org.apache.stratos.cloud.controller.domain.PortMapping;
+import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.common.Properties;
+import org.apache.stratos.common.Property;
+import org.apache.stratos.common.beans.NameValuePair;
+import org.apache.stratos.common.constants.StratosConstants;
+import org.apache.stratos.kubernetes.client.model.EnvironmentVariable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Kubernetes IaaS utility methods.
+ */
+public class KubernetesIaasUtil {
+
+    private static final Log log = LogFactory.getLog(KubernetesIaas.class);
+
+    /**
+     * Prepare and returns the list of ports defined in the given cartridge.
+     * @param cartridge
+     * @return
+     */
+    public static List<Integer> prepareCartridgePorts(Cartridge cartridge) {
+        List<Integer> portList = new ArrayList<Integer>();
+        for (PortMapping portMapping : cartridge.getPortMappings()) {
+            portList.add(Integer.valueOf(portMapping.getPort()));
+        }
+        return portList;
+    }
+
+    /**
+     * Prepare and returns kubernetes service id using clusterId, port protocol and port.
+     * @param portMapping
+     * @return
+     */
+    public static String prepareKubernetesServiceId(String clusterId, PortMapping portMapping) {
+        String serviceId = String.format("%s-%s-%s", clusterId, portMapping.getProtocol(), portMapping.getPort());
+        if(serviceId.contains(".")) {
+            serviceId = serviceId.replace(".", "-");
+        }
+        return serviceId;
+    }
+
+    /**
+     * Prepare and returns environment variables for the given member.
+     * @param clusterContext
+     * @param memberContext
+     * @return
+     */
+    public static EnvironmentVariable[] prepareEnvironmentVariables(ClusterContext clusterContext,
+                                                                     MemberContext memberContext) {
+
+        String kubernetesClusterId = CloudControllerUtil.getProperty(clusterContext.getProperties(),
+                StratosConstants.KUBERNETES_CLUSTER_ID);
+
+        List<EnvironmentVariable> environmentVariables = new ArrayList<EnvironmentVariable>();
+
+        // Set dynamic payload
+        List<NameValuePair> payload = memberContext.getDynamicPayload();
+        if (payload != null) {
+            for (NameValuePair parameter : payload) {
+                addToEnvironmentVariables(environmentVariables, parameter.getName(), parameter.getValue());
+            }
+        }
+
+        // Set member properties
+        Properties properties = memberContext.getProperties();
+        if (properties != null) {
+            for (Property property : properties.getProperties()) {
+                addToEnvironmentVariables(environmentVariables, property.getName(),
+                        property.getValue());
+            }
+        }
+
+        // Set kubernetes cluster id
+        addToEnvironmentVariables(environmentVariables, StratosConstants.KUBERNETES_CLUSTER_ID,
+                kubernetesClusterId);
+
+        if (log.isDebugEnabled()) {
+            log.debug(String.format("Environment variables: [cluster-id] %s [member-id] %s [variables] %s",
+                    memberContext.getClusterId(), memberContext.getMemberId(), environmentVariables.toString()));
+        }
+
+        EnvironmentVariable[] array = new EnvironmentVariable[environmentVariables.size()];
+        return environmentVariables.toArray(array);
+    }
+
+    private static void addToEnvironment(List<EnvironmentVariable> envVars, String payload) {
+        if (payload != null) {
+            String[] entries = payload.split(",");
+            for (String entry : entries) {
+                String[] var = entry.split("=");
+                if (var.length != 2) {
+                    continue;
+                }
+                addToEnvironmentVariables(envVars, var[0], var[1]);
+            }
+        }
+    }
+
+    private static void addToEnvironmentVariables(List<EnvironmentVariable> envVars, String name, String value) {
+        EnvironmentVariable var = new EnvironmentVariable();
+        var.setName(name);
+        var.setValue(value);
+        envVars.add(var);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesPartitionValidator.java
new file mode 100644
index 0000000..0c79309
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesPartitionValidator.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.cloud.controller.iaases.kubernetes;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.context.CloudControllerContext;
+import org.apache.stratos.cloud.controller.domain.IaasProvider;
+import org.apache.stratos.cloud.controller.domain.Partition;
+import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
+import org.apache.stratos.cloud.controller.exception.NonExistingKubernetesClusterException;
+import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
+
+import java.util.Properties;
+
+/**
+ * Kubernetes partition validator
+ */
+public class KubernetesPartitionValidator implements PartitionValidator {
+
+    private static final Log log = LogFactory.getLog(KubernetesPartitionValidator.class);
+
+    private IaasProvider iaasProvider;
+
+    @Override
+    public void setIaasProvider(IaasProvider iaasProvider) {
+        this.iaasProvider = iaasProvider;
+    }
+
+    /**
+     * Validate the given properties for its existent in this partition.
+     *
+     * @param partition  partition.
+     * @param properties set of properties to be validated.
+     * @return cloned and modified {@link IaasProvider} which maps to the given partition.
+     * @throws InvalidPartitionException if at least one property is evaluated to be invalid.
+     */
+    public IaasProvider validate(Partition partition, Properties properties) throws InvalidPartitionException {
+
+        String kubernetesClusterId = partition.getKubernetesClusterId();
+        if (StringUtils.isBlank(kubernetesClusterId)) {
+            String message = "Kubernetes cluster id not found in partition: [partition-id] " + partition.getId();
+            log.error(message);
+            throw new InvalidPartitionException(message);
+        }
+
+        try {
+            CloudControllerContext.getInstance().getKubernetesCluster(kubernetesClusterId);
+            return iaasProvider;
+        } catch (NonExistingKubernetesClusterException e) {
+            String message = "Kubernetes partition is not valid: [partition-id] " + partition.getId();
+            log.error(message, e);
+            throw new InvalidPartitionException(message, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockAutoscalingFactor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockAutoscalingFactor.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockAutoscalingFactor.java
deleted file mode 100644
index aac0f2d..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockAutoscalingFactor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock;
-
-/**
- * Mock autoscaling factor enumeration
- */
-public enum MockAutoscalingFactor {
-    MemoryConsumption, LoadAverage, RequestInFlight
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockConstants.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockConstants.java
deleted file mode 100644
index cdd3490..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockConstants.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock;
-
-/**
- * Mock constant definitions.
- */
-public class MockConstants {
-    public static final int MAX_MOCK_MEMBER_COUNT = 100;
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIPAddressPool.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIPAddressPool.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIPAddressPool.java
deleted file mode 100644
index ac16a0e..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIPAddressPool.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.registry.RegistryManager;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Mock IP address pool is a singleton class for managing mocked private and public IP addresses.
- */
-public class MockIPAddressPool {
-    private static final Log log = LogFactory.getLog(MockIPAddressPool.class);
-
-    private static final String MOCK_IAAS_PRIVATE_IP_SEQUENCE = "/mock/iaas/private-ip-sequence";
-    private static final String MOCK_IAAS_PUBLIC_IP_SEQUENCE = "/mock/iaas/public-ip-sequence";
-    private static final String PRIVATE_IP_PREFIX = "10.0.0.";
-    private static final String PUBLIC_IP_PREFIX = "20.0.0.";
-
-    private static volatile MockIPAddressPool instance;
-
-    private AtomicInteger privateIpSequence;
-    private AtomicInteger publicIpSequence;
-
-    private MockIPAddressPool() {
-        privateIpSequence = readFromRegistry(MOCK_IAAS_PRIVATE_IP_SEQUENCE);
-        if (privateIpSequence == null) {
-            privateIpSequence = new AtomicInteger();
-        }
-
-        publicIpSequence = readFromRegistry(MOCK_IAAS_PUBLIC_IP_SEQUENCE);
-        if (publicIpSequence == null) {
-            publicIpSequence = new AtomicInteger();
-        }
-    }
-
-    public static MockIPAddressPool getInstance() {
-        if (instance == null) {
-            synchronized (MockIPAddressPool.class) {
-                if (instance == null) {
-                    instance = new MockIPAddressPool();
-                }
-            }
-        }
-        return instance;
-    }
-
-    public String getNextPrivateIpAddress() {
-        int nextSequence = privateIpSequence.incrementAndGet();
-        String ipAddress = PRIVATE_IP_PREFIX + nextSequence;
-        persistInRegistry(MOCK_IAAS_PRIVATE_IP_SEQUENCE, privateIpSequence);
-        if (log.isInfoEnabled()) {
-            log.info("Mock private IP address allocated: " + ipAddress);
-        }
-        return ipAddress;
-    }
-
-    public String getNextPublicIpAddress() {
-        int nextSequence = publicIpSequence.incrementAndGet();
-        String ipAddress = PUBLIC_IP_PREFIX + nextSequence;
-        persistInRegistry(MOCK_IAAS_PRIVATE_IP_SEQUENCE, publicIpSequence);
-        if (log.isInfoEnabled()) {
-            log.info("Mock public IP address allocated: " + ipAddress);
-        }
-        return ipAddress;
-    }
-
-    private void persistInRegistry(String resourcePath, Serializable serializable) {
-        try {
-            RegistryManager.getInstance().persist(resourcePath, serializable);
-        } catch (RegistryException e) {
-            log.error(String.format("Could not persist mock iaas ip sequence [%s] in registry", resourcePath), e);
-        }
-    }
-
-    private AtomicInteger readFromRegistry(String resourcePath) {
-        return (AtomicInteger) RegistryManager.getInstance().read(resourcePath);
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaas.java
new file mode 100644
index 0000000..8203793
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaas.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.stratos.cloud.controller.iaases.mock;
+
+import org.apache.stratos.cloud.controller.domain.IaasProvider;
+import org.apache.stratos.cloud.controller.domain.MemberContext;
+import org.apache.stratos.cloud.controller.domain.Partition;
+import org.apache.stratos.cloud.controller.exception.*;
+import org.apache.stratos.cloud.controller.iaases.Iaas;
+import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
+import org.apache.stratos.cloud.controller.iaases.mock.service.MockIaasService;
+
+/**
+ * Mock IaaS client for invoking mock IaaS service.
+ */
+public class MockIaas extends Iaas {
+
+    public MockIaas(IaasProvider iaasProvider) {
+        super(iaasProvider);
+    }
+
+    @Override
+    public void initialize() {
+    }
+
+    @Override
+    public MemberContext startInstance(MemberContext memberContext) {
+        return MockIaasService.getInstance().createInstance(memberContext);
+    }
+
+    @Override
+    public void releaseAddress(String ip) {
+        MockIaasService.getInstance().releaseAddress(ip);
+    }
+
+    @Override
+    public boolean isValidRegion(String region) throws InvalidRegionException {
+        return MockIaasService.getInstance().isValidRegion(region);
+    }
+
+    @Override
+    public boolean isValidZone(String region, String zone) throws InvalidZoneException, InvalidRegionException {
+        return MockIaasService.getInstance().isValidZone(region, zone);
+    }
+
+    @Override
+    public boolean isValidHost(String zone, String host) throws InvalidHostException {
+        return MockIaasService.getInstance().isValidHost(zone, host);
+    }
+
+    @Override
+    public PartitionValidator getPartitionValidator() {
+        return MockIaasService.getInstance().getPartitionValidator();
+    }
+
+    @Override
+    public String createVolume(int sizeGB, String snapshotId) {
+        return MockIaasService.getInstance().createVolume(sizeGB, snapshotId);
+    }
+
+    @Override
+    public String attachVolume(String instanceId, String volumeId, String deviceName) {
+        return MockIaasService.getInstance().attachVolume(instanceId, volumeId, deviceName);
+    }
+
+    @Override
+    public void detachVolume(String instanceId, String volumeId) {
+        MockIaasService.getInstance().detachVolume(instanceId, volumeId);
+    }
+
+    @Override
+    public void deleteVolume(String volumeId) {
+        MockIaasService.getInstance().deleteVolume(volumeId);
+    }
+
+    @Override
+    public String getIaasDevice(String device) {
+        return MockIaasService.getInstance().getIaasDevice(device);
+    }
+
+    @Override
+    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition) {
+        MockIaasService.getInstance().allocateIpAddress(clusterId, memberContext, partition);
+    }
+
+    @Override
+    public void setDynamicPayload(byte[] payload) {
+        MockIaasService.getInstance().setDynamicPayload(payload);
+    }
+
+    @Override
+    public void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException, InvalidMemberException {
+        MockIaasService.getInstance().terminateInstance(memberContext);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java
deleted file mode 100644
index 6fcd52f..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.domain.*;
-import org.apache.stratos.cloud.controller.exception.*;
-import org.apache.stratos.cloud.controller.iaases.mock.config.MockIaasConfig;
-import org.apache.stratos.cloud.controller.iaases.mock.statistics.generator.MockHealthStatisticsGenerator;
-import org.apache.stratos.cloud.controller.iaases.validators.PartitionValidator;
-import org.apache.stratos.cloud.controller.registry.RegistryManager;
-import org.apache.stratos.common.threading.StratosThreadPool;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-
-/**
- * Mock IaaS service implementation. This is a singleton class that simulates a standard Infrastructure as a Service
- * platform by creating mock members and managing their lifecycle states.
- *
- * How does this work:
- * - Mock IaaS starts a Mock Member thread or each instance created
- * - A sample private IP and a public IP will be assigned to the instance
- * - Mock Member will publish Instance Started and Instance Activated events once the thread is started
- * - Afterwards it will start publishing sample health statistics values to CEP
- * - If the Mock IaaS was asked to terminate an instance it will stop the relevant thread
- */
-public class MockIaasService {
-
-    private static final Log log = LogFactory.getLog(MockIaasService.class);
-
-    private static final ExecutorService mockMemberExecutorService =
-            StratosThreadPool.getExecutorService("MOCK_MEMBER_EXECUTOR_SERVICE", MockConstants.MAX_MOCK_MEMBER_COUNT);
-    private static final String MOCK_IAAS_MEMBERS = "/mock/iaas/members";
-    private static volatile MockIaasService instance;
-
-    private MockPartitionValidator partitionValidator;
-    // Map<ServiceName, Map<MemberId,MockMember>>
-    private Map<String, Map<String, MockMember>> serviceNameToMockMemberMap;
-
-    private MockIaasService() {
-        super();
-        partitionValidator = new MockPartitionValidator();
-        serviceNameToMockMemberMap = readFromRegistry();
-        if(serviceNameToMockMemberMap == null) {
-            // No members found in registry, create a new map
-            serviceNameToMockMemberMap = new ConcurrentHashMap<String, Map<String, MockMember>>();
-        }
-    }
-
-    public static MockIaasService getInstance() {
-        if (instance == null) {
-            synchronized (MockIaasService.class) {
-                if (instance == null) {
-                    if(!MockIaasConfig.getInstance().isEnabled()) {
-                        throw new RuntimeException("Mock IaaS is not enabled");
-                    }
-                    instance = new MockIaasService();
-                }
-            }
-        }
-        return instance;
-    }
-
-    /**
-     * Start mock members
-     */
-    public void startMockMembers() {
-        if(serviceNameToMockMemberMap != null) {
-            for(Map.Entry<String, Map<String, MockMember>> serviceNameEntry : serviceNameToMockMemberMap.entrySet())  {
-                // Start mock members
-                for(Map.Entry<String, MockMember> memberEntry : serviceNameEntry.getValue().entrySet()) {
-                    mockMemberExecutorService.submit(memberEntry.getValue());
-                }
-
-                // Schedule statistics updater tasks for service
-                if(serviceNameEntry.getValue().entrySet().size() > 0) {
-                    MockHealthStatisticsGenerator.getInstance().scheduleStatisticsUpdaterTasks(serviceNameEntry.getKey());
-                }
-            }
-        }
-    }
-
-    public MemberContext createInstance(MemberContext memberContext) {
-        synchronized (MockIaasService.class) {
-            // Create mock member instance
-            MockMemberContext mockMemberContext = new MockMemberContext(memberContext.getCartridgeType(),
-                    memberContext.getClusterId(), memberContext.getMemberId(), memberContext.getInstanceId(),
-                    memberContext.getClusterInstanceId(), memberContext.getNetworkPartitionId(),
-                    memberContext.getPartition().getId());
-
-            MockMember mockMember = new MockMember(mockMemberContext);
-            addMemberToMap(mockMember);
-            mockMemberExecutorService.submit(mockMember);
-
-            // Generate instance id
-            memberContext.setInstanceId(UUID.randomUUID().toString());
-
-            // Persist changes
-            persistInRegistry();
-
-            String serviceName = mockMemberContext.getServiceName();
-            MockHealthStatisticsGenerator.getInstance().scheduleStatisticsUpdaterTasks(serviceName);
-
-            return memberContext;
-        }
-    }
-
-    private void addMemberToMap(MockMember mockMember) {
-        String serviceName = mockMember.getMockMemberContext().getServiceName();
-        Map<String, MockMember> memberMap = serviceNameToMockMemberMap.get(serviceName);
-        if(memberMap == null) {
-            memberMap = new ConcurrentHashMap<String, MockMember>();
-            serviceNameToMockMemberMap.put(serviceName, memberMap);
-        }
-        memberMap.put(mockMember.getMockMemberContext().getMemberId(), mockMember);
-    }
-
-    private void persistInRegistry() {
-        try {
-            RegistryManager.getInstance().persist(MOCK_IAAS_MEMBERS,
-                    (ConcurrentHashMap<String, Map<String, MockMember>>)serviceNameToMockMemberMap);
-        } catch (RegistryException e) {
-            log.error("Could not persist mock iaas members in registry", e);
-        }
-    }
-
-    private ConcurrentHashMap<String, Map<String, MockMember>> readFromRegistry() {
-        return (ConcurrentHashMap<String, Map<String, MockMember>>)
-                RegistryManager.getInstance().read(MOCK_IAAS_MEMBERS);
-    }
-
-    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition) {
-        // Allocate mock ip addresses
-        memberContext.setDefaultPrivateIP(MockIPAddressPool.getInstance().getNextPrivateIpAddress());
-        memberContext.setDefaultPublicIP(MockIPAddressPool.getInstance().getNextPublicIpAddress());
-    }
-
-    public void releaseAddress(String ip) {
-
-    }
-
-    public boolean isValidRegion(String region) throws InvalidRegionException {
-        return true;
-    }
-
-    public boolean isValidZone(String region, String zone) throws InvalidZoneException, InvalidRegionException {
-        return true;
-    }
-
-    public boolean isValidHost(String zone, String host) throws InvalidHostException {
-        return true;
-    }
-
-    public PartitionValidator getPartitionValidator() {
-        return partitionValidator;
-    }
-
-    public String createVolume(int sizeGB, String snapshotId) {
-        return null;
-    }
-
-    public String attachVolume(String instanceId, String volumeId, String deviceName) {
-        return null;
-    }
-
-    public void detachVolume(String instanceId, String volumeId) {
-
-    }
-
-    public void deleteVolume(String volumeId) {
-
-    }
-
-    public String getIaasDevice(String device) {
-        return null;
-    }
-
-    public void setDynamicPayload(byte[] payload) {
-
-    }
-
-    public void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException, InvalidMemberException {
-        synchronized (MockIaasService.class) {
-            String serviceName = memberContext.getCartridgeType();
-            Map<String, MockMember> memberMap = serviceNameToMockMemberMap.get(serviceName);
-            if(memberMap != null) {
-                MockMember mockMember = memberMap.get(memberContext.getMemberId());
-                if(mockMember != null) {
-                    if (mockMember != null) {
-                        mockMember.terminate();
-                        memberMap.remove(memberContext.getMemberId());
-                    }
-
-                    if (memberMap.size() == 0) {
-                        MockHealthStatisticsGenerator.getInstance().stopStatisticsUpdaterTasks(serviceName);
-                    }
-                }
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMember.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMember.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMember.java
deleted file mode 100644
index 87e14ee..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMember.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.iaases.mock.statistics.publisher.MockHealthStatisticsNotifier;
-import org.apache.stratos.common.threading.StratosThreadPool;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupClusterEvent;
-import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupMemberEvent;
-import org.apache.stratos.messaging.listener.instance.notifier.InstanceCleanupClusterEventListener;
-import org.apache.stratos.messaging.listener.instance.notifier.InstanceCleanupMemberEventListener;
-import org.apache.stratos.messaging.message.receiver.instance.notifier.InstanceNotifierEventReceiver;
-
-import java.io.Serializable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Mock member definition.
- */
-public class MockMember implements Runnable, Serializable {
-
-    private static final Log log = LogFactory.getLog(MockMember.class);
-    private static final ExecutorService instanceNotifierExecutorService =
-            StratosThreadPool.getExecutorService("MOCK_MEMBER_INSTANCE_NOTIFIER_EXECUTOR_SERVICE", 20);
-    private static final ScheduledExecutorService healthStatNotifierExecutorService =
-            StratosThreadPool.getScheduledExecutorService("MOCK_MEMBER_HEALTH_STAT_NOTIFIER_EXECUTOR_SERVICE", 20);
-    private static final int HEALTH_STAT_INTERVAL = 15; // 15 seconds
-
-    private final MockMemberContext mockMemberContext;
-    private boolean terminated;
-
-    public MockMember(MockMemberContext mockMemberContext) {
-        this.mockMemberContext = mockMemberContext;
-    }
-
-    @Override
-    public void run() {
-        if (log.isInfoEnabled()) {
-            log.info(String.format("Mock member started: [member-id] %s", mockMemberContext.getMemberId()));
-        }
-
-        sleep(5000);
-        MockMemberEventPublisher.publishInstanceStartedEvent(mockMemberContext);
-
-        sleep(5000);
-        MockMemberEventPublisher.publishInstanceActivatedEvent(mockMemberContext);
-
-        startInstanceNotifierReceiver();
-        startHealthStatisticsPublisher();
-
-        while (!terminated) {
-            sleep(1000);
-        }
-
-        if (log.isInfoEnabled()) {
-            log.info(String.format("Mock member terminated: [member-id] %s", mockMemberContext.getMemberId()));
-        }
-    }
-
-    private void startInstanceNotifierReceiver() {
-        if (log.isDebugEnabled()) {
-            log.debug("Starting instance notifier event message receiver");
-        }
-
-        final InstanceNotifierEventReceiver instanceNotifierEventReceiver = new InstanceNotifierEventReceiver();
-        instanceNotifierEventReceiver.addEventListener(new InstanceCleanupClusterEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                InstanceCleanupClusterEvent instanceCleanupClusterEvent = (InstanceCleanupClusterEvent) event;
-                if (mockMemberContext.getClusterId().equals(instanceCleanupClusterEvent.getClusterId()) &&
-                        mockMemberContext.getClusterInstanceId().equals(
-                                instanceCleanupClusterEvent.getClusterInstanceId())) {
-                    handleMemberTermination();
-                }
-            }
-        });
-
-        instanceNotifierEventReceiver.addEventListener(new InstanceCleanupMemberEventListener() {
-            @Override
-            protected void onEvent(Event event) {
-                InstanceCleanupMemberEvent instanceCleanupClusterEvent = (InstanceCleanupMemberEvent) event;
-                if (mockMemberContext.getMemberId().equals(instanceCleanupClusterEvent.getMemberId())) {
-                    handleMemberTermination();
-                }
-            }
-        });
-
-        instanceNotifierExecutorService.submit(new Runnable() {
-            @Override
-            public void run() {
-                instanceNotifierEventReceiver.execute();
-            }
-        });
-
-        if (log.isDebugEnabled()) {
-            log.debug("Instance notifier event message receiver started");
-        }
-    }
-
-    private void handleMemberTermination() {
-        MockMemberEventPublisher.publishMaintenanceModeEvent(mockMemberContext);
-        sleep(2000);
-        MockMemberEventPublisher.publishInstanceReadyToShutdownEvent(mockMemberContext);
-    }
-
-    private void startHealthStatisticsPublisher() {
-        if (log.isDebugEnabled()) {
-            log.debug(String.format("Starting health statistics notifier: [member-id] %s", mockMemberContext.getMemberId()));
-        }
-
-        healthStatNotifierExecutorService.scheduleAtFixedRate(new MockHealthStatisticsNotifier(mockMemberContext),
-                0, HEALTH_STAT_INTERVAL, TimeUnit.SECONDS);
-
-        if (log.isDebugEnabled()) {
-            log.debug(String.format("Health statistics notifier started: [member-id] %s", mockMemberContext.getMemberId()));
-        }
-    }
-
-    private void sleep(long time) {
-        try {
-            Thread.sleep(time);
-        } catch (InterruptedException ignore) {
-            terminate();
-        }
-    }
-
-    public MockMemberContext getMockMemberContext() {
-        return mockMemberContext;
-    }
-
-    public void terminate() {
-        terminated = true;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java
deleted file mode 100644
index a217218..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock;
-
-import java.io.Serializable;
-
-/**
- * Mock member context.
- */
-public class MockMemberContext implements Serializable {
-    private final String serviceName;
-    private final String clusterId;
-    private final String memberId;
-    private final String instanceId;
-    private final String clusterInstanceId;
-    private final String networkPartitionId;
-    private final String partitionId;
-
-    public MockMemberContext(String serviceName, String clusterId, String memberId, String instanceId,
-                             String clusterInstanceId, String networkPartitionId, String partitionId) {
-        this.serviceName = serviceName;
-        this.clusterId = clusterId;
-        this.memberId = memberId;
-        this.instanceId = instanceId;
-        this.clusterInstanceId = clusterInstanceId;
-        this.networkPartitionId = networkPartitionId;
-        this.partitionId = partitionId;
-    }
-
-    public String getServiceName() {
-        return serviceName;
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public String getMemberId() {
-        return memberId;
-    }
-
-    public String getInstanceId() {
-        return instanceId;
-    }
-
-    public String getClusterInstanceId() {
-        return clusterInstanceId;
-    }
-
-    public String getNetworkPartitionId() {
-        return networkPartitionId;
-    }
-
-    public String getPartitionId() {
-        return partitionId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java
deleted file mode 100644
index 1499e00..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent;
-import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent;
-import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent;
-import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * Mock member event publisher.
- */
-public class MockMemberEventPublisher {
-
-    private static final Log log = LogFactory.getLog(MockMemberEventPublisher.class);
-
-    public static void publishInstanceStartedEvent(MockMemberContext mockMemberContext) {
-        if (log.isInfoEnabled()) {
-            log.info("Publishing instance started event");
-        }
-        InstanceStartedEvent event = new InstanceStartedEvent(
-                mockMemberContext.getServiceName(),
-                mockMemberContext.getClusterId(),
-                mockMemberContext.getMemberId(),
-                mockMemberContext.getClusterInstanceId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId());
-        String topic = Util.getMessageTopicName(event);
-        EventPublisher eventPublisher = EventPublisherPool
-                .getPublisher(topic);
-        eventPublisher.publish(event);
-        if (log.isInfoEnabled()) {
-            log.info("Instance started event published");
-        }
-    }
-
-    public static void publishInstanceActivatedEvent(MockMemberContext mockMemberContext) {
-        if (log.isInfoEnabled()) {
-            log.info("Publishing instance activated event");
-        }
-        InstanceActivatedEvent event = new InstanceActivatedEvent(
-                mockMemberContext.getServiceName(),
-                mockMemberContext.getClusterId(),
-                mockMemberContext.getMemberId(),
-                mockMemberContext.getInstanceId(),
-                mockMemberContext.getClusterInstanceId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId());
-
-        // Event publisher connection will
-        String topic = Util.getMessageTopicName(event);
-        EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
-        eventPublisher.publish(event);
-        if (log.isInfoEnabled()) {
-            log.info("Instance activated event published");
-        }
-    }
-
-    public static void publishInstanceReadyToShutdownEvent(MockMemberContext mockMemberContext) {
-        if (log.isInfoEnabled()) {
-            log.info(String.format("Publishing instance ready to shutdown event: [member-id] %s",
-                    mockMemberContext.getMemberId()));
-        }
-        InstanceReadyToShutdownEvent event = new InstanceReadyToShutdownEvent(
-                mockMemberContext.getServiceName(),
-                mockMemberContext.getClusterId(),
-                mockMemberContext.getMemberId(),
-                mockMemberContext.getClusterInstanceId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId());
-        String topic = Util.getMessageTopicName(event);
-        EventPublisher eventPublisher = EventPublisherPool
-                .getPublisher(topic);
-        eventPublisher.publish(event);
-        if (log.isInfoEnabled()) {
-            log.info(String.format("Instance ready to shutDown event published: [member-id] %s",
-                    mockMemberContext.getMemberId()));
-        }
-    }
-
-    public static void publishMaintenanceModeEvent(MockMemberContext mockMemberContext) {
-        if (log.isInfoEnabled()) {
-            log.info(String.format("Publishing instance maintenance mode event: [member-id] %s",
-                    mockMemberContext.getMemberId()));
-        }
-        InstanceMaintenanceModeEvent event = new InstanceMaintenanceModeEvent(
-                mockMemberContext.getServiceName(),
-                mockMemberContext.getClusterId(),
-                mockMemberContext.getMemberId(),
-                mockMemberContext.getClusterInstanceId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId());
-        String topic = Util.getMessageTopicName(event);
-        EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
-        eventPublisher.publish(event);
-
-        if (log.isInfoEnabled()) {
-            log.info(String.format("Instance Maintenance mode event published: [member-id] %s",
-                    mockMemberContext.getMemberId()));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java
index d3ca6d6..fbea11b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java
@@ -22,7 +22,7 @@ package org.apache.stratos.cloud.controller.iaases.mock;
 import org.apache.stratos.cloud.controller.domain.IaasProvider;
 import org.apache.stratos.cloud.controller.domain.Partition;
 import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
-import org.apache.stratos.cloud.controller.iaases.validators.PartitionValidator;
+import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
 
 import java.util.Properties;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockHealthStatisticsConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockHealthStatisticsConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockHealthStatisticsConfig.java
deleted file mode 100644
index 28975c2..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockHealthStatisticsConfig.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock.config;
-
-import org.apache.stratos.cloud.controller.iaases.mock.statistics.generator.MockHealthStatisticsPattern;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Mock health statistics configuration.
- */
-public class MockHealthStatisticsConfig {
-    List<MockHealthStatisticsPattern> statisticsPatternList;
-
-    public MockHealthStatisticsConfig() {
-        statisticsPatternList = new ArrayList<MockHealthStatisticsPattern>();
-    }
-
-    public void addStatisticsPattern(MockHealthStatisticsPattern statisticsPattern) {
-        statisticsPatternList.add(statisticsPattern);
-    }
-
-    public List<MockHealthStatisticsPattern> getStatisticsPatterns() {
-        return statisticsPatternList;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/e195f2f1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockIaasConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockIaasConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockIaasConfig.java
deleted file mode 100644
index 8e47f18..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/config/MockIaasConfig.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.cloud.controller.iaases.mock.config;
-
-/**
- * Mock iaas configuration.
- */
-public class MockIaasConfig {
-    private static final String MOCK_IAAS_CONFIG_FILE_NAME = "mock-iaas.xml";
-    private static final String CARBON_HOME = "carbon.home";
-    private static final String REPOSITORY_CONF = "/repository/conf/";
-
-    private static volatile MockIaasConfig instance;
-
-    private boolean enabled;
-    private MockHealthStatisticsConfig mockHealthStatisticsConfig;
-    
-    public static MockIaasConfig getInstance() {
-        if (instance == null) {
-            synchronized (MockIaasConfig.class) {
-                if (instance == null) {
-                    String confPath = System.getProperty(CARBON_HOME) + REPOSITORY_CONF;
-                    instance = MockIaasConfigParser.parse(confPath + MOCK_IAAS_CONFIG_FILE_NAME);
-                }
-            }
-        }
-        return instance;
-    }
-
-    MockIaasConfig() {
-    }
-
-    void setEnabled(boolean enabled) {
-        this.enabled = enabled;
-    }
-
-    void setMockHealthStatisticsConfig(MockHealthStatisticsConfig mockHealthStatisticsConfig) {
-        this.mockHealthStatisticsConfig = mockHealthStatisticsConfig;
-    }
-
-    public MockHealthStatisticsConfig getMockHealthStatisticsConfig() {
-        return mockHealthStatisticsConfig;
-    }
-
-    public boolean isEnabled() {
-        return enabled;
-    }
-}


Mime
View raw message