adding service group deployment to auto scaler

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

Branch: refs/heads/4.0.0-grouping
Commit: 836b71fd7a0d4258cf4b397d5cc43228c477ffa0
Parents: 686d0e0
Author: Udara Liyanage <[email protected]>
Authored: Fri Oct 31 15:36:45 2014 +0530
Committer: Udara Liyanage <[email protected]>
Committed: Fri Oct 31 16:06:02 2014 +0530

----------------------------------------------------------------------
 .../autoscaler/api/AutoScalerServiceImpl.java   |  78 +-
 .../exception/InvalidServiceGroupException.java |  46 +
 .../stratos/autoscaler/pojo/Dependencies.java   |  46 +
 .../stratos/autoscaler/pojo/ServiceGroup.java   |  67 ++
 .../autoscaler/registry/RegistryManager.java    |  47 +-
 .../autoscaler/util/AutoScalerConstants.java    |   3 +-
 .../stratos/autoscaler/util/Deserializer.java   |  10 +-
 .../manager/client/AutoscalerServiceClient.java |  20 +-
 .../deployer/DefaultServiceGroupDeployer.java   |  39 +-
 .../pom.xml                                     |   3 +-
 .../src/main/resources/AutoScalerService.wsdl   | 892 +++++++++++--------
 11 files changed, 846 insertions(+), 405 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
index 897fd4e..d710bf7 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java
@@ -18,22 +18,25 @@
  */
 package org.apache.stratos.autoscaler.api;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
 import 
org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
-import org.apache.stratos.autoscaler.exception.InvalidPartitionException;
-import org.apache.stratos.autoscaler.exception.InvalidPolicyException;
-import org.apache.stratos.autoscaler.exception.NonExistingLBException;
-import org.apache.stratos.autoscaler.exception.PartitionValidationException;
+import org.apache.stratos.autoscaler.exception.*;
 import org.apache.stratos.autoscaler.interfaces.AutoScalerServiceInterface;
 import org.apache.stratos.autoscaler.partition.PartitionGroup;
 import org.apache.stratos.autoscaler.partition.PartitionManager;
+import org.apache.stratos.autoscaler.pojo.Dependencies;
+import org.apache.stratos.autoscaler.pojo.ServiceGroup;
 import org.apache.stratos.autoscaler.policy.PolicyManager;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+import org.apache.stratos.autoscaler.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
+import org.wso2.carbon.registry.api.RegistryException;
 
+import java.text.MessageFormat;
 import java.util.ArrayList;
 
 /**
@@ -268,5 +271,72 @@ public class AutoScalerServiceImpl implements 
AutoScalerServiceInterface{
         
     }
 
+    public void deployServiceGroup(ServiceGroup servicegroup) throws 
InvalidServiceGroupException {
+
+        if (servicegroup == null || 
StringUtils.isEmpty(servicegroup.getName())) {
+            String msg = "Service group can not be null service name can not 
be empty.";
+            log.error(msg);
+            throw new IllegalArgumentException(msg);
+
+        }
+        String name = servicegroup.getName();
+
+        if(RegistryManager.getInstance().serviceGroupExist(name)){
+            throw new InvalidServiceGroupException("Service group with the 
name " + name + " already exist.");
+        }
+
+        if(log.isDebugEnabled()) {
+            log.debug(MessageFormat.format("Deploying service group {0}", 
servicegroup.getName()));
+        }
+
+        String [] subGroups = servicegroup.getCartridges();
+
+        if(log.isDebugEnabled()) {
+            log.debug("SubGroups" + subGroups);
+            if (subGroups != null) {
+                log.debug("subGroups:size" + subGroups.length);
+            } else {
+                log.debug("subGroups: are null");
+            }
+        }
+
+
+        Dependencies dependencies = servicegroup.getDependencies();
+
+        if(log.isDebugEnabled()) {
+            log.debug("Dependencies" + dependencies);
+        }
+
+        if (dependencies != null) {
+            String [] startupOrders = dependencies.getStartupOrders();
+
+            if(log.isDebugEnabled()) {
+                log.debug("StartupOrders" + startupOrders);
+
+                if (startupOrders != null) {
+                    log.debug("StartupOrder:size" + startupOrders.length);
+                } else {
+                    log.debug("StartupOrder: is null");
+                }
+            }
+        }
+
+        RegistryManager.getInstance().persistServiceGroup(servicegroup);
+    }
+
+    public ServiceGroup getServiceGroup(String name){
+        if(StringUtils.isEmpty(name)){
+            return null;
+        }
+        try {
+            return RegistryManager.getInstance().getServiceGroup(name);
+        } catch (Exception e) {
+            throw new AutoScalerException("Error occurred while retrieving 
service groups", e);
+        }
+    }
+    public boolean serviceGroupExist(String serviceName){
+        return false;
+    }
+
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java
new file mode 100644
index 0000000..d18c274
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.autoscaler.exception;
+
+public class InvalidServiceGroupException extends Exception {
+
+
+    private static final long serialVersionUID = 2651280146514042590L;
+
+    private String message;
+
+    public InvalidServiceGroupException(String msg) {
+        super(msg);
+        this.setMessage(msg);
+    }
+
+    public InvalidServiceGroupException(String msg, Exception ex) {
+        super(msg, ex);
+        this.setMessage(msg);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java
new file mode 100644
index 0000000..4403e6c
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java
@@ -0,0 +1,46 @@
+/*
+ * 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.autoscaler.pojo;
+
+import java.io.Serializable;
+
+public class Dependencies implements Serializable {
+
+    private static final long serialVersionUID = 4187267350546153680L;
+
+    private String [] startupOrders;
+
+    private String killBehaviour;
+
+    public String getKillBehaviour() {
+        return killBehaviour;
+    }
+
+    public void setKillBehaviour(String killBehaviour) {
+        this.killBehaviour = killBehaviour;
+    }
+
+    public String[] getStartupOrders() {
+        return startupOrders;
+    }
+
+    public void setStartupOrders(String[] startupOrders) {
+        this.startupOrders = startupOrders;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java
new file mode 100644
index 0000000..4de6e0c
--- /dev/null
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java
@@ -0,0 +1,67 @@
+/*
+ * 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.autoscaler.pojo;
+
+import java.io.Serializable;
+
+public class ServiceGroup implements Serializable {
+
+
+    private static final long serialVersionUID = -7413745300105885793L;
+
+    private String name;
+
+    private String [] subGroups;
+
+    private String [] cartridges;
+
+    private Dependencies dependencies;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String [] getSubGroups() {
+        return subGroups;
+    }
+
+    public void setSubGroups(String [] subGroups) {
+        this.subGroups = subGroups;
+    }
+
+    public String [] getCartridges() {
+        return cartridges;
+    }
+
+    public void setCartridges(String [] cartridges) {
+        this.cartridges = cartridges;
+    }
+
+    public Dependencies getDependencies() {
+        return dependencies;
+    }
+
+    public void setDependencies(Dependencies dependencies) {
+        this.dependencies = dependencies;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
index 25caf0e..ee8e411 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java
@@ -21,11 +21,13 @@ package org.apache.stratos.autoscaler.registry;
 */
 
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.NetworkPartitionLbHolder;
 import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
 import org.apache.stratos.autoscaler.exception.AutoScalerException;
+import org.apache.stratos.autoscaler.pojo.ServiceGroup;
 import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
 import org.apache.stratos.autoscaler.util.AutoScalerConstants;
 import org.apache.stratos.autoscaler.util.Deserializer;
@@ -142,6 +144,7 @@ public class RegistryManager {
         }
     }
 
+
     public void persistApplication (Application application) {
 
         String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + 
AutoScalerConstants.APPLICATIONS_RESOURCE +
@@ -181,13 +184,27 @@ public class RegistryManager {
         }
         return null;
     }
+
+    public void persistServiceGroup(ServiceGroup servicegroup) {
+        if(servicegroup == null || 
StringUtils.isEmpty(servicegroup.getName())){
+            throw new  IllegalArgumentException("Service group or group name 
can not be null");
+        }
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + 
AutoScalerConstants.SERVICE_GROUP + "/" + servicegroup.getName();
+        persist(servicegroup, resourcePath);
+        if(log.isDebugEnabled()) {
+            log.debug(String.format("Persisted service group %s at path %s", 
servicegroup.getName(), resourcePath));
+        }
+    }
+
+    public boolean serviceGroupExist(String serviceGroupName){
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + 
AutoScalerConstants.SERVICE_GROUP + "/" + serviceGroupName;
+        return this.resourceExist(resourcePath);
+    }
     
     private Object retrieve(String resourcePath) {
         try {
             Resource resource = registryService.get(resourcePath);
-           
             return resource.getContent();
-
         } catch (ResourceNotFoundException ignore) {
             // this means, we've never persisted info in registry
             return null;
@@ -198,6 +215,10 @@ public class RegistryManager {
         }
     }
 
+    private boolean resourceExist(String resourcePath){
+        return  this.retrieve(resourcePath) != null;
+    }
+
     public List<Partition> retrievePartitions() {
         List<Partition> partitionList = new ArrayList<Partition>();
         RegistryManager registryManager = RegistryManager.getInstance();
@@ -327,6 +348,26 @@ public class RegistryManager {
         return depPolicyList;
     }
 
+    public ServiceGroup getServiceGroup(String name) throws Exception{
+        String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + 
AutoScalerConstants.SERVICE_GROUP + "/" + name;
+        Object serializedObj = registryManager.retrieve(resourcePath);
+        ServiceGroup group = null;
+        if (serializedObj != null) {
+
+                Object dataObj = 
Deserializer.deserializeFromByteArray((byte[]) serializedObj);
+                if (dataObj instanceof ServiceGroup) {
+                    group = (ServiceGroup) dataObj;
+                    if(log.isDebugEnabled()) {
+                        log.debug(group.toString());
+                    }
+                } else {
+                    return null;
+                }
+        }
+
+        return group;
+    }
+
        public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) {
                 String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE 
+ AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId();
          this.delete(resourcePath);
@@ -372,6 +413,6 @@ public class RegistryManager {
                    log.error("Could not delete resource at "+ resourcePath);
                    throw new AutoScalerException("Could not delete data in 
registry at " + resourcePath, e);
                }
-               
+
        }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
index b30e0e6..3587afe 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java
@@ -44,5 +44,6 @@ public final class AutoScalerConstants {
      * Configs
      */
     public static final String AUTOSCALER_MONITOR_INTERVAL = 
"autoscaler.monitorInterval";
-       
+
+    public static final String SERVICE_GROUP = "/groups";
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
index 5c97143..af1c6ea 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java
@@ -18,15 +18,11 @@
  */
 package org.apache.stratos.autoscaler.util;
 
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.io.*;
+
 public class Deserializer {
     
     private static final Log log = LogFactory.getLog(Deserializer.class);
@@ -75,7 +71,7 @@ public class Deserializer {
      * @return the deserialized {@link Object}
      * @throws Exception if the deserialization is failed.
      */
-    public static Object deserializeFromByteArray(byte[] bytes) throws 
Exception {
+    public static Object deserializeFromByteArray(byte[] bytes) throws 
IOException, ClassNotFoundException {
 
         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
         ObjectInput in = null;

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
index b87d0f2..731c80f 100644
--- 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
+++ 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
@@ -24,15 +24,13 @@ import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
+import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
+import org.apache.stratos.autoscaler.stub.*;
+import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
 import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition;
 import org.apache.stratos.manager.internal.DataHolder;
 import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy;
-import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy;
-import 
org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException;
-import 
org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException;
-import 
org.apache.stratos.autoscaler.stub.AutoScalerServiceNonExistingLBExceptionException;
-import org.apache.stratos.autoscaler.stub.AutoScalerServiceStub;
 
 import java.rmi.RemoteException;
 
@@ -211,5 +209,13 @@ public class AutoscalerServiceClient {
     public String getServiceLBClusterId (String serviceType, String 
deploymentPolicy) throws RemoteException {
        return stub.getServiceLBClusterId(serviceType, deploymentPolicy);
     }
-    
+
+
+    public ServiceGroup getServiceGroup(String serviceGroupDefinitionName) 
throws RemoteException {
+        return stub.getServiceGroup(serviceGroupDefinitionName);
+    }
+
+    public void deployServiceGroup(ServiceGroup serviceGroup) throws 
AutoScalerServiceInvalidServiceGroupExceptionException, RemoteException {
+        stub.deployServiceGroup(serviceGroup);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
index be0c4ee..7244de4 100644
--- 
a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
+++ 
b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
@@ -22,23 +22,21 @@ package org.apache.stratos.manager.grouping.deployer;
 import org.apache.axis2.AxisFault;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.pojo.Dependencies;
+import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
+import 
org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidServiceGroupExceptionException;
+import 
org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException;
+import 
org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
+import org.apache.stratos.manager.client.AutoscalerServiceClient;
 import org.apache.stratos.manager.client.CloudControllerServiceClient;
 import org.apache.stratos.manager.exception.ADCException;
 import org.apache.stratos.manager.exception.InvalidServiceGroupException;
 import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
 import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
-import org.apache.stratos.cloud.controller.stub.pojo.ServiceGroup;
-import org.apache.stratos.cloud.controller.stub.pojo.Dependencies;
-import 
org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException;
-import 
org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
+import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
 
 import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 public class DefaultServiceGroupDeployer implements ServiceGroupDeployer {
 
@@ -155,23 +153,23 @@ public class DefaultServiceGroupDeployer implements 
ServiceGroupDeployer {
             }
         }
         
-        CloudControllerServiceClient ccServiceClient = null;
+        AutoscalerServiceClient asServiceClient = null;
 
         try {
-            ccServiceClient = CloudControllerServiceClient.getServiceClient();
+            asServiceClient = AutoscalerServiceClient.getServiceClient();
             
             if (log.isDebugEnabled()) {
                log.debug("deplying to cloud controller service group " + 
serviceGroupDefinition.getName());
             }
-            
-            ccServiceClient.deployServiceGroup(serviceGroup);
+
+            asServiceClient.deployServiceGroup(serviceGroup);
 
         } catch (AxisFault axisFault) {
             throw new ADCException(axisFault);
         }catch (RemoteException e) {
             throw new ADCException(e);
-        } catch (CloudControllerServiceInvalidServiceGroupExceptionException 
e) {
-               throw new ADCException(e);
+        } catch (AutoScalerServiceInvalidServiceGroupExceptionException e) {
+            e.printStackTrace();
         }
     }
 
@@ -181,16 +179,16 @@ public class DefaultServiceGroupDeployer implements 
ServiceGroupDeployer {
                log.debug("getting service group from cloud controller " + 
serviceGroupDefinitionName);
         }
        
-       CloudControllerServiceClient ccServiceClient = null;
+       AutoscalerServiceClient asServiceClient = null;
 
         try {
-            ccServiceClient = CloudControllerServiceClient.getServiceClient();
+            asServiceClient = AutoscalerServiceClient.getServiceClient();
             
             if (log.isDebugEnabled()) {
                log.debug("deploying to cloud controller service group " + 
serviceGroupDefinitionName);
             }
             
-            ServiceGroup serviceGroup = 
ccServiceClient.getServiceGroup(serviceGroupDefinitionName);
+            ServiceGroup serviceGroup = 
asServiceClient.getServiceGroup(serviceGroupDefinitionName);
             ServiceGroupDefinition serviceGroupDef = 
populateServiceGroupDefinitionPojo(serviceGroup);
             
             return serviceGroupDef;
@@ -199,10 +197,7 @@ public class DefaultServiceGroupDeployer implements 
ServiceGroupDeployer {
             throw new ADCException(axisFault);
         } catch (RemoteException e) {
                throw new ADCException(e);
-               } catch 
(CloudControllerServiceInvalidServiceGroupExceptionException e) {
-                       throw new ADCException(e);
                }
-       
     }
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/836b71fd/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
----------------------------------------------------------------------
diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml 
b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
index 60683cc..0df7903 100644
--- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
+++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml
@@ -47,7 +47,7 @@
                         <configuration>
                             <tasks>
                                 <java 
classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
-                                    <arg line="-uri 
src/main/resources/AutoScalerService.wsdl -u -uw -o target/generated-code -p 
org.apache.stratos.autoscaler.stub -ns2p 
http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.partition";
 />
+                                    <arg line="-uri 
src/main/resources/AutoScalerService.wsdl -u -uw -o target/generated-code -p 
org.apache.stratos.autoscaler.stub -ns2p 
http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.partition,http://pojo.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.pojo";
 />
                                     <classpath 
refid="maven.dependency.classpath" />
                                     <classpath refid="maven.compile.classpath" 
/>
                                     <classpath refid="maven.runtime.classpath" 
/>
@@ -93,6 +93,7 @@
                             org.apache.stratos.autoscaler.exception.*; 
version=${project.version},
                            org.apache.stratos.autoscaler.partition.*; 
version=${project.version},
                            org.apache.stratos.autoscaler.api.*; 
version=${project.version}
+                           org.apache.stratos.autoscaler.pojo.*; 
version=${project.version}
                         </Export-Package>
                        <Private-Package>
                        </Private-Package>

Reply via email to