stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [3/3] stratos git commit: Update the application runtime with network partition id
Date Wed, 02 Sep 2015 09:55:08 GMT
Update the application runtime with network partition id


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

Branch: refs/heads/master
Commit: 23a01363c9c293d9527cafd1429761b95a81a053
Parents: 39de79a
Author: gayangunarathne <gayang@wso2.com>
Authored: Wed Sep 2 15:24:25 2015 +0530
Committer: gayangunarathne <gayang@wso2.com>
Committed: Wed Sep 2 15:24:25 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41Utils.java   |  8 +++---
 .../util/converter/ObjectConverter.java         | 26 +++++++++++++++++---
 2 files changed, 27 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/23a01363/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index b22eacd..958f1cd 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -2098,7 +2098,7 @@ public class StratosApiV41Utils {
      * @param application             Application
      */
     private static void addGroupsInstancesToApplicationInstanceBean(ApplicationInstanceBean
applicationInstanceBean,
-                                                                    Application application)
{
+                                                                    Application application)
throws RestAPIException {
         Collection<Group> groups = application.getGroups();
         if (groups != null && !groups.isEmpty()) {
             for (Group group : groups) {
@@ -2120,7 +2120,7 @@ public class StratosApiV41Utils {
      * @param application             Application
      */
     private static void addClustersInstancesToApplicationInstanceBean(
-            ApplicationInstanceBean applicationInstanceBean, Application application) {
+            ApplicationInstanceBean applicationInstanceBean, Application application) throws
RestAPIException {
 
         Map<String, ClusterDataHolder> topLevelClusterDataMap = application.getClusterDataMap();
         if (topLevelClusterDataMap != null) {
@@ -2150,7 +2150,7 @@ public class StratosApiV41Utils {
      */
     private static void addClustersInstancesToGroupInstanceBean(
             GroupInstanceBean groupInstanceBean,
-            Group group) {
+            Group group) throws RestAPIException {
         Map<String, ClusterDataHolder> topLevelClusterDataMap = group.getClusterDataMap();
         if (topLevelClusterDataMap != null && !topLevelClusterDataMap.isEmpty())
{
             for (Map.Entry<String, ClusterDataHolder> entry : topLevelClusterDataMap.entrySet())
{
@@ -2177,7 +2177,7 @@ public class StratosApiV41Utils {
      * @param group             Group
      * @param groupInstanceBean GroupInstanceBean
      */
-    private static void setSubGroupInstances(Group group, GroupInstanceBean groupInstanceBean)
{
+    private static void setSubGroupInstances(Group group, GroupInstanceBean groupInstanceBean)
throws RestAPIException {
         Collection<Group> subgroups = group.getGroups();
         addClustersInstancesToGroupInstanceBean(groupInstanceBean, group);
         if (subgroups != null && !subgroups.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/23a01363/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index 7ba6dea..eea8434 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -20,6 +20,8 @@
 package org.apache.stratos.rest.endpoint.util.converter;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy;
 import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicy;
 import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
@@ -70,6 +72,8 @@ import java.util.*;
 
 public class ObjectConverter {
 
+    private static final Log log = LogFactory.getLog(ObjectConverter.class);
+
     public static final String CLUSTER_PROPERTY = "cluster";
 
     public static Cartridge convertCartridgeBeanToStubCartridgeConfig(
@@ -700,7 +704,7 @@ public class ObjectConverter {
     }
 
     public static ClusterInstanceBean convertClusterToClusterInstanceBean(String instanceId,
-                                                                          Cluster cluster,
String alias) {
+                                                                          Cluster cluster,
String alias) throws RestAPIException {
         ClusterInstanceBean clusterInstanceBean = new ClusterInstanceBean();
         clusterInstanceBean.setAlias(alias);
         clusterInstanceBean.setServiceName(cluster.getServiceName());
@@ -721,8 +725,24 @@ public class ObjectConverter {
                 MemberBean memberBean = new MemberBean();
                 memberBean.setClusterId(member.getClusterId());
                 memberBean.setLbClusterId(member.getLbClusterId());
-                memberBean.setNetworkPartitionId(member.getNetworkPartitionId());
-                memberBean.setPartitionId(member.getPartitionId());
+                NetworkPartition netWorkPartition=null;
+                try {
+                    netWorkPartition= CloudControllerServiceClient.getInstance().getNetworkPartition(member.getNetworkPartitionId());
+                } catch (RemoteException e) {
+                    log.error("Error when getting the network partition");
+                    throw new RestAPIException(e);
+                }
+
+                if(netWorkPartition!=null) {
+                   memberBean.setNetworkPartitionId(netWorkPartition.getId());
+                   Partition[] partition = netWorkPartition.getPartitions();
+                   for(int i=0;i<partition.length;i++){
+                       if(partition[i].getUuid().equals(member.getPartitionId())){
+                           memberBean.setPartitionId(partition[i].getId());
+                       }
+                   }
+                }
+
                 memberBean.setMemberId(member.getMemberId());
                 memberBean.setClusterInstanceId(member.getClusterInstanceId());
                 memberBean.setDefaultPrivateIP(member.getDefaultPrivateIP());


Mime
View raw message