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:03 UTC

[06/26] git commit: refactoring registerService operation to take an argument called Registrant

refactoring registerService operation to take an argument called Registrant


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

Branch: refs/heads/master
Commit: 2e06dd195ca811c6ba91bad997225d08f5c37eee
Parents: 4eae601
Author: Nirmal Fernando <ni...@apache.org>
Authored: Fri Nov 22 14:20:42 2013 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Fri Nov 22 14:20:42 2013 +0530

----------------------------------------------------------------------
 .../impl/CloudControllerServiceImpl.java        | 20 +++--
 .../interfaces/CloudControllerService.java      | 20 +----
 .../cloud/controller/pojo/Registrant.java       | 81 ++++++++++++++++++++
 3 files changed, 96 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/2e06dd19/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 bcb5cd6..67b7aea 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
@@ -19,6 +19,7 @@
 package org.apache.stratos.cloud.controller.impl;
 
 import com.google.common.collect.Lists;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -27,6 +28,7 @@ import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeExcept
 import org.apache.stratos.cloud.controller.exception.UnregisteredServiceException;
 import org.apache.stratos.cloud.controller.interfaces.CloudControllerService;
 import org.apache.stratos.cloud.controller.persist.Deserializer;
+import org.apache.stratos.cloud.controller.pojo.Registrant;
 import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisherTask;
 import org.apache.stratos.cloud.controller.registry.RegistryManager;
 import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder;
@@ -951,19 +953,21 @@ public class CloudControllerServiceImpl implements CloudControllerService {
 	}
 
 	@Override
-	public boolean registerService(String clusterId,
-			String tenantRange, String cartridgeType, String hostName,
-			Properties properties, String payload, String autoScalerPolicyName)
+	public boolean registerService(Registrant registrant)
 			throws UnregisteredCartridgeException {
 
+	    String clusterId = registrant.getClusterId();
+	    
 		// create a ServiceContext dynamically
 		ServiceContext newServiceCtxt = new ServiceContext();
-		newServiceCtxt.setClusterId(clusterId);
+        newServiceCtxt.setClusterId(clusterId);
 		//newServiceCtxt.setSubDomainName(subDomain);
-		newServiceCtxt.setTenantRange(tenantRange);
-		newServiceCtxt.setHostName(hostName);
-        newServiceCtxt.setAutoScalerPolicyName(autoScalerPolicyName);
-        newServiceCtxt.setPayload(new StringBuilder(payload));
+		newServiceCtxt.setTenantRange(registrant.getTenantRange());
+		newServiceCtxt.setHostName(registrant.getHostName());
+        newServiceCtxt.setAutoScalerPolicyName(registrant.getAutoScalerPolicyName());
+        newServiceCtxt.setPayload(new StringBuilder(registrant.getPayload()));
+        Properties properties = registrant.getProperties();
+        String cartridgeType = registrant.getCartridgeType();
 
 		if (properties != null && properties.getProperties() != null) {
 			// add properties

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/2e06dd19/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 a657d02..eac4281 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
@@ -20,8 +20,8 @@ package org.apache.stratos.cloud.controller.interfaces;
 
 import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeException;
 import org.apache.stratos.cloud.controller.exception.UnregisteredServiceException;
+import org.apache.stratos.cloud.controller.pojo.Registrant;
 import org.apache.stratos.cloud.controller.util.CartridgeInfo;
-import org.apache.stratos.cloud.controller.util.Properties;
 import org.apache.stratos.messaging.domain.topology.Partition;
 
 import java.util.List;
@@ -40,28 +40,14 @@ public interface CloudControllerService {
      * present service cluster, if there is any. A service cluster is uniquely identified by its
      * domain and sub domain combination.
      * </p>
-     * @param clusterId
-     *            service cluster domain
-     * @param tenantRange
-     * 			  tenant range eg: '1-10' or '2'
-     * @param cartridgeType
-     *            cartridge type of the new service. This should be an already registered cartridge
-     *            type.
-     * @param hostName
-     * 			  host name of this service instance
-     * @param properties
-     * 			  Set of properties related to this service definition.
-     * @param payload
-     *            payload which will be passed to instance to be started. Payload shouldn't contain 
-     *            xml tags.
+     * @param registrant information about the new subscription.
      * @return whether the registration is successful or not.
      * 
      * @throws UnregisteredCartridgeException
      *             when the cartridge type requested by this service is
      *             not a registered one.
      */
-    public boolean registerService(String clusterId, String tenantRange, String cartridgeType,
-        String hostName, Properties properties, String payload, String autoScalerPolicyName) throws UnregisteredCartridgeException;
+    public boolean registerService(Registrant registrant) throws UnregisteredCartridgeException;
 
     /**
      * Calling this method will result in an instance startup, which is belong

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/2e06dd19/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java
new file mode 100644
index 0000000..e9bc8c2
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import org.apache.stratos.cloud.controller.util.Properties;
+
+/**
+ * Upon a new subscription, Stratos Manager would send this POJO.
+ * @author nirmal
+ *
+ */
+public class Registrant {
+
+    private String clusterId;
+    private String tenantRange;
+    private String cartridgeType;
+    private String hostName;
+    private Properties properties;
+    private String payload;
+    private String autoScalerPolicyName;
+    
+    public String getClusterId() {
+        return clusterId;
+    }
+    public void setClusterId(String clusterId) {
+        this.clusterId = clusterId;
+    }
+    public String getTenantRange() {
+        return tenantRange;
+    }
+    public void setTenantRange(String tenantRange) {
+        this.tenantRange = tenantRange;
+    }
+    public String getCartridgeType() {
+        return cartridgeType;
+    }
+    public void setCartridgeType(String cartridgeType) {
+        this.cartridgeType = cartridgeType;
+    }
+    public String getHostName() {
+        return hostName;
+    }
+    public void setHostName(String hostName) {
+        this.hostName = hostName;
+    }
+    public Properties getProperties() {
+        return properties;
+    }
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+    public String getPayload() {
+        return payload;
+    }
+    public void setPayload(String payload) {
+        this.payload = payload;
+    }
+    public String getAutoScalerPolicyName() {
+        return autoScalerPolicyName;
+    }
+    public void setAutoScalerPolicyName(String autoScalerPolicyName) {
+        this.autoScalerPolicyName = autoScalerPolicyName;
+    }
+    
+}