You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by re...@apache.org on 2014/11/04 06:56:01 UTC

[3/8] git commit: sending app cluster information to CC via a service call - initial stuff

sending app cluster information to CC via a service call - initial stuff


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

Branch: refs/heads/docker-grouping-merge
Commit: d8874e28e85a83c8438a4d2b552f2c604dc1ac22
Parents: b9467d6
Author: Isuru Haththotuwa <is...@apache.org>
Authored: Mon Nov 3 12:18:03 2014 +0530
Committer: reka <rt...@gmail.com>
Committed: Tue Nov 4 11:18:01 2014 +0530

----------------------------------------------------------------------
 .../impl/CloudControllerServiceImpl.java        | 69 ++++++++++++++++----
 .../pojo/ApplicationClusterContextDTO.java      | 10 ++-
 .../controller/topology/TopologyBuilder.java    |  4 +-
 3 files changed, 67 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/d8874e28/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
index d43cc8c..21878ad 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java
@@ -1064,8 +1064,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
         String property = props.getProperty(Constants.IS_LOAD_BALANCER);
         boolean isLb = property != null ? Boolean.parseBoolean(property) : false;
 
-        ClusterContext ctxt = buildClusterContext(cartridge, clusterId,
-				payload, hostName, props, isLb, registrant.getPersistence());
+        ClusterContext ctxt = null;//TODO buildClusterContext(cartridge, clusterId,
+				//payload, hostName, props, isLb, registrant.getPersistence());
 
 
 		dataHolder.addClusterContext(ctxt);
@@ -1080,15 +1080,15 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 
 	private ClusterContext buildClusterContext(Cartridge cartridge,
                                                String clusterId, String payload, String hostName,
-                                               Properties props, boolean isLb, Persistence persistence) {
+                                               org.apache.stratos.common.Properties props, boolean isLb, Persistence persistence) {
 
-
-		// initialize ClusterContext
+        //TODO
+		/*// initialize ClusterContext
 		ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, 
 				hostName, isLb, props);
 		
 		String property;
-		property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT);
+		property = props.get(Constants.GRACEFUL_SHUTDOWN_TIMEOUT);
 		long timeout = property != null ? Long.parseLong(property) : 30000;
 
         boolean persistanceRequired = false;
@@ -1103,7 +1103,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
             ctxt.setVolumeRequired(false);
         }
 	    ctxt.setTimeoutInMillis(timeout);
-		return ctxt;
+		return ctxt;*/
+        return null;
 	}
 
     @Override
@@ -1897,6 +1898,50 @@ public class CloudControllerServiceImpl implements CloudControllerService {
             throw new IllegalArgumentException(errorMsg);
         }
     }
+    public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts)  throws
+            ApplicationClusterRegistrationException {
+
+        // Create a Cluster Context obj. for each of the Clusters in the Application
+        if (appClustersContexts == null || appClustersContexts.length == 0) {
+            String errorMsg = "No application cluster information found, unable to create clusters" ;
+            LOG.error(errorMsg);
+            throw new ApplicationClusterRegistrationException(errorMsg);
+        }
+
+        //TODO
+
+        /*for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
+            dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),
+                    appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(),
+                    appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties()));
+        }
+*/
+        persist();
+    }
+
+//    public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException {
+//
+//        ApplicationParser applicationParser = new DefaultApplicationParser();
+//        Application application = applicationParser.parse(applicationContext);
+//
+//        // Create a Cluster Context obj. for each of the Clusters in the Application
+//        for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) {
+//            dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(),
+//                    applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(),
+//                    applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster()));
+//        }
+//
+//        /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(),
+//                applicationParser.getPayloadData());
+//*/
+//        persist();
+//    }
+//
+//    @Override
+//    public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException {
+//
+//        //TopologyBuilder.handleApplicationUndeployed(applicationId);
+//    }
 
     public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts)  throws
             ApplicationClusterRegistrationException {
@@ -1904,7 +1949,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
         // Create a Cluster Context obj. for each of the Clusters in the Application
         if (appClustersContexts == null || appClustersContexts.length == 0) {
             String errorMsg = "No application cluster information found, unable to create clusters" ;
-            log.error(errorMsg);
+            LOG.error(errorMsg);
             throw new ApplicationClusterRegistrationException(errorMsg);
         }
 
@@ -1912,9 +1957,10 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 
         for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) {
             // add the context data
-            dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),
+            //TODO
+            /*dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(),
                     appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(),
-                    appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties()));
+                    appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties()));*/
             // create Cluster objects
             Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(),
                     appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId);
@@ -1922,7 +1968,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
             newCluster.setTenantRange("*");
             newCluster.setStatus(ClusterStatus.Created);
             newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName()));
-            newCluster.setProperties(appClusterCtxt.getProperties());
+            //newCluster.setProperties(appClusterCtxt.getProperties());
             clusters.add(newCluster);
         }
 
@@ -1954,7 +2000,6 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 //
 //        //TopologyBuilder.handleApplicationUndeployed(applicationId);
 //    }
->>>>>>> 4.0.0-grouping
 
 }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d8874e28/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java
index 1d4dda0..875f7bc 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java
@@ -19,7 +19,8 @@
 
 package org.apache.stratos.cloud.controller.pojo;
 
-import java.util.Properties;
+
+import org.apache.stratos.common.Properties;
 
 public class ApplicationClusterContextDTO {
 
@@ -33,6 +34,8 @@ public class ApplicationClusterContextDTO {
     private String hostName;
     // flag to indicate LB cluster
     private boolean isLbCluster;
+    // flag to indicate Kubernetes cluster
+    private boolean isKubernetesCluster;
     // autoscaling policy
     private String autoscalePolicyName;
     // deployment policy
@@ -46,6 +49,7 @@ public class ApplicationClusterContextDTO {
     public ApplicationClusterContextDTO () {
     }
 
+
     public String getClusterId() {
         return clusterId;
     }
@@ -116,7 +120,7 @@ public class ApplicationClusterContextDTO {
             return false;
         }
 
-        if(this == other) {
+        if (this == other) {
             return true;
         }
 
@@ -126,7 +130,7 @@ public class ApplicationClusterContextDTO {
                 this.clusterId.equals(that.clusterId);
     }
 
-    public int hashCode () {
+    public int hashCode() {
         return this.cartridgeType.hashCode() + this.clusterId.hashCode();
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/d8874e28/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
index dbb6098..6015d87 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java
@@ -174,6 +174,7 @@ public class TopologyBuilder {
         }
 
         TopologyEventPublisher.sendApplicationClustersCreated(appId, appClusters);
+
     }
 
 
@@ -441,7 +442,8 @@ public class TopologyBuilder {
                         instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId());
 
         // grouping - set grouid
-        memberActivatedEvent.setGroupId(instanceActivatedEvent.getGroupId());
+        //TODO
+        memberActivatedEvent.setApplicationId(null);
         try {
             TopologyManager.acquireWriteLock();
             // try update lifecycle state