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/3841007c
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3841007c
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3841007c

Branch: refs/heads/docker-grouping-merge
Commit: 3841007cf0949953aab920385c29303c0363dcac
Parents: eac9d65
Author: Isuru Haththotuwa <[email protected]>
Authored: Mon Nov 3 12:18:03 2014 +0530
Committer: Isuru Haththotuwa <[email protected]>
Committed: Mon Nov 3 12:56:30 2014 +0530

----------------------------------------------------------------------
 ...ApplicationClusterRegistrationException.java |  47 +++++++
 .../impl/CloudControllerServiceImpl.java        |  20 +++
 .../interfaces/CloudControllerService.java      |   2 +
 .../pojo/ApplicationClusterContext.java         | 137 -------------------
 .../pojo/ApplicationClusterContextDTO.java      | 137 +++++++++++++++++++
 .../controller/topology/TopologyBuilder.java    |   5 +
 6 files changed, 211 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/3841007c/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java
new file mode 100644
index 0000000..af2a383
--- /dev/null
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java
@@ -0,0 +1,47 @@
+/*
+ * 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.exception;
+
+public class ApplicationClusterRegistrationException extends Exception {
+
+    private String message;
+
+    public ApplicationClusterRegistrationException () {
+        super();
+    }
+
+    public ApplicationClusterRegistrationException (String message, Throwable 
cause) {
+        super(message, cause);
+        this.message = message;
+    }
+
+    public ApplicationClusterRegistrationException (String message) {
+        super(message);
+        this.message = message;
+    }
+
+    public ApplicationClusterRegistrationException (Throwable cause) {
+        super(cause);
+    }
+
+    public String getMessage() {
+        return message;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/3841007c/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 a914946..19c87f8 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
@@ -1387,6 +1387,26 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         return dataHolder.getClusterContext(clusterId);
     }
 
+    @Override
+    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);
+        }
+
+        for (ApplicationClusterContextDTO appClusterCtxt : 
appClustersContexts) {
+            dataHolder.addClusterContext(new 
ClusterContext(appClusterCtxt.getClusterId(),
+                    appClusterCtxt.getCartridgeType(), 
appClusterCtxt.getTextPayload(),
+                    appClusterCtxt.getHostName(), 
appClusterCtxt.isLbCluster()));
+        }
+
+        persist();
+    }
+
 //    public void deployApplicationDefinition (ApplicationContext 
applicationContext) throws ApplicationDefinitionException {
 //
 //        ApplicationParser applicationParser = new DefaultApplicationParser();

http://git-wip-us.apache.org/repos/asf/stratos/blob/3841007c/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
index 016e98e..e9f526a 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java
@@ -167,4 +167,6 @@ public interface CloudControllerService {
      */
     public ClusterContext getClusterContext (String clusterId);
 
+    public void registerApplicationClusters (ApplicationClusterContextDTO [] 
appClustersContexts) throws
+            ApplicationClusterRegistrationException;
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/3841007c/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java
deleted file mode 100644
index 8fa9fee..0000000
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java
+++ /dev/null
@@ -1,137 +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.pojo;
-
-public class ApplicationClusterContext {
-
-    // cluster id
-    private String clusterId;
-    // cartridge type
-    private String cartridgeType;
-    // payload as a String
-    private String textPayload;
-    // host name
-    private String hostName;
-    // flag to indicate LB cluster
-    private boolean isLbCluster;
-    // autoscaling policy
-    private String autoscalePolicyName;
-    // deployment policy
-    private String deploymentPolicyName;
-    // tenant rance
-    private String tenantRange;
-
-    public ApplicationClusterContext (String cartridgeType, String clusterId, 
String hostName,
-                                      String textPayload, String 
deploymentPolicyName, boolean isLbCluster) {
-
-        this.cartridgeType = cartridgeType;
-        this.clusterId = clusterId;
-        this.hostName = hostName;
-        this.textPayload = textPayload;
-        this.deploymentPolicyName = deploymentPolicyName;
-        this.isLbCluster = isLbCluster;
-        this.tenantRange = "*";
-    }
-
-    public String getClusterId() {
-        return clusterId;
-    }
-
-    public void setClusterId(String clusterId) {
-        this.clusterId = clusterId;
-    }
-
-    public String getCartridgeType() {
-        return cartridgeType;
-    }
-
-    public void setCartridgeType(String cartridgeType) {
-        this.cartridgeType = cartridgeType;
-    }
-
-    public String getTextPayload() {
-        return textPayload;
-    }
-
-    public void setTextPayload(String textPayload) {
-        this.textPayload = textPayload;
-    }
-
-    public String getHostName() {
-        return hostName;
-    }
-
-    public void setHostName(String hostName) {
-        this.hostName = hostName;
-    }
-
-    public boolean isLbCluster() {
-        return isLbCluster;
-    }
-
-    public void setLbCluster(boolean lbCluster) {
-        isLbCluster = lbCluster;
-    }
-
-    public String getAutoscalePolicyName() {
-        return autoscalePolicyName;
-    }
-
-    public void setAutoscalePolicyName(String autoscalePolicyName) {
-        this.autoscalePolicyName = autoscalePolicyName;
-    }
-
-    public String getDeploymentPolicyName() {
-        return deploymentPolicyName;
-    }
-
-    public void setDeploymentPolicyName(String deploymentPolicyName) {
-        this.deploymentPolicyName = deploymentPolicyName;
-    }
-
-    public String getTenantRange() {
-        return tenantRange;
-    }
-
-    public void setTenantRange(String tenantRange) {
-        this.tenantRange = tenantRange;
-    }
-
-    public boolean equals(Object other) {
-
-        if(other == null || !(other instanceof ApplicationClusterContext)) {
-            return false;
-        }
-
-        if(this == other) {
-            return true;
-        }
-
-        ApplicationClusterContext that = (ApplicationClusterContext)other;
-
-        return this.cartridgeType.equals(that.cartridgeType) &&
-                this.clusterId.equals(that.clusterId);
-    }
-
-    public int hashCode () {
-        return this.cartridgeType.hashCode() + this.clusterId.hashCode();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/3841007c/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
new file mode 100644
index 0000000..2b601e0
--- /dev/null
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java
@@ -0,0 +1,137 @@
+/*
+ * 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.pojo;
+
+public class ApplicationClusterContextDTO {
+
+    // cluster id
+    private String clusterId;
+    // cartridge type
+    private String cartridgeType;
+    // payload as a String
+    private String textPayload;
+    // host name
+    private String hostName;
+    // flag to indicate LB cluster
+    private boolean isLbCluster;
+    // autoscaling policy
+    private String autoscalePolicyName;
+    // deployment policy
+    private String deploymentPolicyName;
+    // tenant rance
+    private String tenantRange;
+
+    public ApplicationClusterContextDTO (String cartridgeType, String 
clusterId, String hostName,
+                                        String textPayload, String 
deploymentPolicyName, boolean isLbCluster) {
+
+        this.cartridgeType = cartridgeType;
+        this.clusterId = clusterId;
+        this.hostName = hostName;
+        this.textPayload = textPayload;
+        this.deploymentPolicyName = deploymentPolicyName;
+        this.isLbCluster = isLbCluster;
+        this.tenantRange = "*";
+    }
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public void setClusterId(String clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getCartridgeType() {
+        return cartridgeType;
+    }
+
+    public void setCartridgeType(String cartridgeType) {
+        this.cartridgeType = cartridgeType;
+    }
+
+    public String getTextPayload() {
+        return textPayload;
+    }
+
+    public void setTextPayload(String textPayload) {
+        this.textPayload = textPayload;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+
+    public boolean isLbCluster() {
+        return isLbCluster;
+    }
+
+    public void setLbCluster(boolean lbCluster) {
+        isLbCluster = lbCluster;
+    }
+
+    public String getAutoscalePolicyName() {
+        return autoscalePolicyName;
+    }
+
+    public void setAutoscalePolicyName(String autoscalePolicyName) {
+        this.autoscalePolicyName = autoscalePolicyName;
+    }
+
+    public String getDeploymentPolicyName() {
+        return deploymentPolicyName;
+    }
+
+    public void setDeploymentPolicyName(String deploymentPolicyName) {
+        this.deploymentPolicyName = deploymentPolicyName;
+    }
+
+    public String getTenantRange() {
+        return tenantRange;
+    }
+
+    public void setTenantRange(String tenantRange) {
+        this.tenantRange = tenantRange;
+    }
+
+    public boolean equals(Object other) {
+
+        if(other == null || !(other instanceof ApplicationClusterContextDTO)) {
+            return false;
+        }
+
+        if(this == other) {
+            return true;
+        }
+
+        ApplicationClusterContextDTO that = 
(ApplicationClusterContextDTO)other;
+
+        return this.cartridgeType.equals(that.cartridgeType) &&
+                this.clusterId.equals(that.clusterId);
+    }
+
+    public int hashCode () {
+        return this.cartridgeType.hashCode() + this.clusterId.hashCode();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/3841007c/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 0ec8f01..2d5d181 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
@@ -147,6 +147,11 @@ public class TopologyBuilder {
         TopologyEventPublisher.sendClusterCreatedEvent(cluster);
     }
 
+    public static void handleApplicationClustersRegisterd () {
+
+
+    }
+
 
     public static void handleClusterReset(ClusterStatusClusterResetEvent 
event) {
 

Reply via email to