You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2013/11/27 19:55:14 UTC
[17/26] git commit: changes to CC client etc. after CC refactoring
changes to CC client etc. after CC refactoring
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/ad818d1b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/ad818d1b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/ad818d1b
Branch: refs/heads/master
Commit: ad818d1b2cd73d3605907e4b0ebfa07330959c46
Parents: 1654262
Author: Nirmal Fernando <ni...@apache.org>
Authored: Wed Nov 27 09:47:04 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Wed Nov 27 09:47:04 2013 +0530
----------------------------------------------------------------------
.../client/CloudControllerServiceClient.java | 51 +++++++++++++++++---
.../manager/CartridgeSubscriptionManager.java | 2 +-
.../mgt/utils/ApplicationManagementUtil.java | 20 ++++++--
3 files changed, 60 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ad818d1b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
index 36db631..7141467 100644
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
+++ b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/client/CloudControllerServiceClient.java
@@ -26,12 +26,16 @@ import org.apache.commons.logging.LogFactory;
import org.apache.stratos.adc.mgt.exception.UnregisteredCartridgeException;
import org.apache.stratos.adc.mgt.internal.DataHolder;
import org.apache.stratos.adc.mgt.utils.CartridgeConstants;
+import org.apache.stratos.cloud.controller.pojo.xsd.Registrant;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceIllegalArgumentExceptionException;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceStub;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
import org.apache.stratos.cloud.controller.util.xsd.CartridgeInfo;
-import org.apache.stratos.cloud.controller.util.xsd.Properties;
+import org.apache.stratos.messaging.util.xsd.Property;
import java.rmi.RemoteException;
+import java.util.Iterator;
+import java.util.Properties;
public class CloudControllerServiceClient {
@@ -70,15 +74,46 @@ public class CloudControllerServiceClient {
public boolean register(String clusterId, String cartridgeType,
String payload, String tenantRange,
String hostName, Properties properties,
- String autoscalorPolicyName) throws RemoteException, CloudControllerServiceUnregisteredCartridgeExceptionException
+ String autoscalorPolicyName) throws RemoteException,
+ CloudControllerServiceUnregisteredCartridgeExceptionException,
+ CloudControllerServiceIllegalArgumentExceptionException
{
- return stub.registerService(clusterId, tenantRange, cartridgeType, hostName,
- properties, payload, autoscalorPolicyName);
+ Registrant registrant = new Registrant();
+ registrant.setClusterId(clusterId);
+ registrant.setCartridgeType(cartridgeType);
+ registrant.setTenantRange(tenantRange);
+ registrant.setHostName(hostName);
+ org.apache.stratos.messaging.util.xsd.Properties props = extractProperties(properties);
+ registrant.setProperties(props);
+ registrant.setPayload(payload);
+ registrant.setAutoScalerPolicyName(autoscalorPolicyName);
+ return stub.registerService(registrant);
}
- public boolean terminateAllInstances(String clusterId) throws Exception {
- return stub.terminateAllInstances(clusterId);
+ private org.apache.stratos.messaging.util.xsd.Properties
+ extractProperties(Properties properties) {
+ org.apache.stratos.messaging.util.xsd.Properties props =
+ new org.apache.stratos.messaging.util.xsd.Properties();
+ if (properties != null) {
+
+ for (Iterator iterator = properties.keySet().iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ String value = properties.getProperty(key);
+
+ Property prop = new Property();
+ prop.setName(key);
+ prop.setValue(value);
+
+ props.addProperties(prop);
+
+ }
+ }
+ return props;
+ }
+
+ public void terminateAllInstances(String clusterId) throws Exception {
+ stub.terminateAllInstances(clusterId);
}
public String[] getRegisteredCartridges() throws Exception {
@@ -95,8 +130,8 @@ public class CloudControllerServiceClient {
}
}
- public boolean unregisterService(String clusterId) throws Exception {
- return stub.unregisterService(clusterId);
+ public void unregisterService(String clusterId) throws Exception {
+ stub.unregisterService(clusterId);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ad818d1b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/manager/CartridgeSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/manager/CartridgeSubscriptionManager.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/manager/CartridgeSubscriptionManager.java
index bf3c938..cb82a4c 100644
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/manager/CartridgeSubscriptionManager.java
+++ b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/manager/CartridgeSubscriptionManager.java
@@ -41,7 +41,7 @@ import org.apache.stratos.adc.mgt.utils.CartridgeConstants;
import org.apache.stratos.adc.mgt.utils.PersistenceManager;
import org.apache.stratos.adc.mgt.utils.PolicyHolder;
import org.apache.stratos.cloud.controller.util.xsd.CartridgeInfo;
-import org.apache.stratos.cloud.controller.util.xsd.Property;
+import org.apache.stratos.messaging.util.xsd.Property;
import org.wso2.carbon.context.CarbonContext;
import java.util.List;
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ad818d1b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/utils/ApplicationManagementUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/utils/ApplicationManagementUtil.java b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/utils/ApplicationManagementUtil.java
index ed8f613..6d673b6 100644
--- a/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/utils/ApplicationManagementUtil.java
+++ b/components/org.apache.stratos.adc.mgt/src/main/java/org/apache/stratos/adc/mgt/utils/ApplicationManagementUtil.java
@@ -22,6 +22,7 @@ package org.apache.stratos.adc.mgt.utils;
import com.google.gson.Gson;
+
import org.apache.axis2.clustering.ClusteringAgent;
import org.apache.axis2.clustering.Member;
import org.apache.axis2.clustering.management.GroupManagementAgent;
@@ -44,10 +45,10 @@ import org.apache.stratos.adc.mgt.repository.Repository;
import org.apache.stratos.adc.mgt.service.RepositoryInfoBean;
import org.apache.stratos.adc.topology.mgt.service.TopologyManagementService;
import org.apache.stratos.adc.topology.mgt.serviceobjects.DomainContext;
+import org.apache.stratos.cloud.controller.stub.CloudControllerServiceIllegalArgumentExceptionException;
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException;
import org.apache.stratos.cloud.controller.util.xsd.CartridgeInfo;
-import org.apache.stratos.cloud.controller.util.xsd.Properties;
-import org.apache.stratos.cloud.controller.util.xsd.Property;
+import org.apache.stratos.messaging.util.xsd.Property;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.LsRemoteCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -62,6 +63,7 @@ import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
+
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
@@ -745,7 +747,6 @@ public class ApplicationManagementUtil {
DecimalFormat df = new DecimalFormat("##.##");
df.setParseBigDecimal(true);
- Properties properties = new Properties();
List<Property> allProperties = new ArrayList<Property>();
// min_app_instances
Property property = new Property();
@@ -802,7 +803,14 @@ public class ApplicationManagementUtil {
property.setValue(String.valueOf(alias));
allProperties.add(property);
- properties.setProperties(allProperties.toArray(new Property[allProperties.size()]));
+ return addToJavaUtilProperties(allProperties);
+ }
+
+ private static Properties addToJavaUtilProperties(List<Property> allProperties) {
+ Properties properties = new Properties();
+ for (Property property : allProperties) {
+ properties.put(property.getName(), property.getValue());
+ }
return properties;
}
@@ -934,6 +942,10 @@ public class ApplicationManagementUtil {
try {
CloudControllerServiceClient.getServiceClient().register(domain, cartridgeType, payload.toString(), tenantRange,
hostName, properties, "economyPolicy");
+ } catch (CloudControllerServiceIllegalArgumentExceptionException e) {
+ String msg = "Exception is occurred in register service operation. Reason :" + e.getMessage();
+ log.error(msg, e);
+ throw new IllegalArgumentException("Not a registered cartridge " + cartridgeType, e);
} catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
String msg = "Exception is occurred in register service operation. Reason :" + e.getMessage();
log.error(msg, e);