http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java deleted file mode 100644 index 940bdea..0000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java +++ /dev/null @@ -1,179 +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.deployment.partition; - -import org.apache.stratos.common.Properties; - -import java.io.Serializable; - -/** - * The model class for Partition definition. - */ -public class Partition implements Serializable{ - - private static final long serialVersionUID = 3725971214092010720L; - private int partitionMax; - private int partitionMin; - /** - * provider should match with an IaasProvider type. - */ - private String provider; - private Properties properties = new Properties(); - private String id; - private String description; - private boolean isPublic; - - - /** - * Gets the value of the partitionMax property. - * - */ - public int getPartitionMax() { - return partitionMax; - } - - /** - * Sets the value of the partitionMax property. - * - */ - public void setPartitionMax(int value) { - this.partitionMax = value; - } - - /** - * Gets the value of the partitionMin property. - * - */ - public int getPartitionMin() { - return partitionMin; - } - - /** - * Sets the value of the partitionMin property. - * - */ - public void setPartitionMin(int value) { - this.partitionMin = value; - } - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(String id) { - this.id = id; - } - - /** - * Gets the value of the description property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDescription() { - return description; - } - - /** - * Sets the value of the description property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Sets the value of the isPublic property. - * - * @param value - * allowed object is boolean - * - */ - public void setIsPublic(boolean isPublic) { - this.isPublic = isPublic; - } - - /** - * Gets the value of the isPublic property. - * - */ - public boolean getIsPublic() { - return isPublic; - } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - - public String getProvider() { - return provider; - } - - public void setProvider(String provider) { - this.provider = provider; - } - - @Override - public String toString() { - return "Partition [id=" + id + ", description=" + description + ", isPublic=" + isPublic - + ", provider=" + provider + ", partitionMin=" + partitionMin + ", partitionMax=" - + partitionMax + ", properties=" + properties + "]"; - } - - public boolean equals(Object obj) { - if(obj != null && obj instanceof Partition) { - return this.id.equals(((Partition) obj).getId()); - } - return false; - - } - - @Override - public int hashCode() { - return this.id.hashCode(); - } - -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/AppType.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/AppType.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/AppType.java new file mode 100644 index 0000000..7a8bb2d --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/AppType.java @@ -0,0 +1,62 @@ +/* + * 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.domain; + +import java.io.Serializable; + +/** + * domain mapping related data. + * + */ +public class AppType implements Serializable{ + + private static final long serialVersionUID = 3550489774139807168L; + private String name; + private boolean appSpecificMapping = true; + + public AppType(){ + + } + + public AppType(String name){ + this.setName(name); + } + + public AppType(String name, boolean appSpecificMapping){ + this.setName(name); + this.setAppSpecificMapping(appSpecificMapping); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isAppSpecificMapping() { + return appSpecificMapping; + } + + public void setAppSpecificMapping(boolean appSpecificMapping) { + this.appSpecificMapping = appSpecificMapping; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ApplicationClusterContextDTO.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ApplicationClusterContextDTO.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ApplicationClusterContextDTO.java new file mode 100644 index 0000000..4258739 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ApplicationClusterContextDTO.java @@ -0,0 +1,143 @@ +/* + * 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.domain; + + +import org.apache.stratos.common.Properties; + +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; + // propertis + private Properties properties; + + + public ApplicationClusterContextDTO () { + } + + + 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(); + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java new file mode 100644 index 0000000..da92b12 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java @@ -0,0 +1,404 @@ +/* + * 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.domain; + +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.Serializable; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Holds information regarding a Cartridge. + */ +public class Cartridge implements Serializable{ + + private transient static final Log log = LogFactory.getLog(Cartridge.class); + private static final long serialVersionUID = 6637409027085059072L; + + private String type; + + private String hostName; + + private String provider; + + private String displayName; + + private String description; + + private String baseDir; + + private String version; + + private boolean multiTenant; + + private String defaultAutoscalingPolicy; + + private String defaultDeploymentPolicy; + + private LoadbalancerConfig lbConfig; + + private List<PortMapping> portMappings; + + private Persistence persistence; + + private List<AppType> appTypeMappings; + + private String serviceGroup; + + private String deployerType; + + /** + * Property map of this Cartridge. + */ + private Map<String, String> properties; + + /** + * A Cartridge can have 1..n {@link IaasProvider}s + */ + private List<IaasProvider> iaases; + + private List<String> deploymentDirs; + + private IaasProvider lastlyUsedIaas; + + private String[] exportingProperties; + + /** + * Key - partition id + * Value - Corresponding IaasProvider. + */ + private Map<String, IaasProvider> partitionToIaasProvider; + + private Container container; + + public Cartridge(){ + init(); + } + + public Cartridge(String type, String host, String provider, String version, boolean multiTenant) { + this.type = type; + this.hostName = host; + this.provider = provider; + this.version = version; + this.multiTenant = multiTenant; + init(); + } + + private void init() { + partitionToIaasProvider = new ConcurrentHashMap<String, IaasProvider>(); + portMappings = new ArrayList<PortMapping>(); + portMappings = new ArrayList<PortMapping>(); + appTypeMappings = new ArrayList<AppType>(); + properties = new HashMap<String, String>(); + iaases = new ArrayList<IaasProvider>(); + deploymentDirs = new ArrayList<String>(); + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public void addIaasProvider(String partitionId, IaasProvider iaasProvider) { + partitionToIaasProvider.put(partitionId, iaasProvider); + } + + public void addIaasProviders(Map<String, IaasProvider> map) { + for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) { + String key = (String) iterator.next(); + IaasProvider value = map.get(key); + + partitionToIaasProvider.put(key, value); + if(log.isDebugEnabled()) { + log.debug("Partition map updated for the Cartridge: "+this.hashCode()+". " + + "Current Partition List: "+partitionToIaasProvider.keySet().toString()); + } + } + } + + public IaasProvider getIaasProviderOfPartition(String partitionId) { + if(log.isDebugEnabled()) { + log.debug("Retrieving partition: "+partitionId+" for the Cartridge: "+this.hashCode()+". " + + "Current Partition List: "+partitionToIaasProvider.keySet().toString()); + } + return partitionToIaasProvider.get(partitionId); + } + + public void addProperty(String key, String val) { + if (key != null && val != null) { + properties.put(key, val); + } + } + + public Map<String, String> getProperties() { + return properties; + } + + public String getProperty(String key) { + return properties.get(key); + } + + public void setProperties(Map<String, String> properties) { + this.properties = properties; + } + + public void addIaasProvider(IaasProvider iaas) { + for (IaasProvider anIaas : iaases) { + if(anIaas.equals(iaas)){ + int idx = iaases.indexOf(anIaas); + iaases.remove(idx); + iaases.add(idx, iaas); + return; + } + } + this.iaases.add(iaas); + } + + public IaasProvider getIaasProvider(String iaasType){ + for (IaasProvider iaas : iaases) { + if(iaas.getType().equals(iaasType)){ + return iaas; + } + } + + return null; + } + + public List<IaasProvider> getIaases() { + return iaases; + } + + @Override + public String toString() { + return "Cartridge [type=" + type + ", hostName=" + hostName + + ", provider=" + provider + ", version=" + version + + ", multiTenant=" + multiTenant + + ", defaultAutoscalingPolicy=" + defaultAutoscalingPolicy + + ", defaultDeploymentPolicy=" + defaultDeploymentPolicy + + ", serviceGroup=" + serviceGroup + ", properties=" + + properties + ", partitionToIaasProvider=" + + partitionToIaasProvider + "]"; + } + + public void setIaases(List<IaasProvider> iaases) { + this.iaases = iaases; + } + + public boolean equals(Object obj) { + if (obj instanceof Cartridge) { + return this.type.equals(((Cartridge)obj).getType()); + } + return false; + } + + public int hashCode() { + return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers + append(type). + toHashCode(); + } + + public IaasProvider getLastlyUsedIaas() { + return lastlyUsedIaas; + } + + public void setLastlyUsedIaas(IaasProvider lastlyUsedIaas) { + this.lastlyUsedIaas = lastlyUsedIaas; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public void reset(){ + } + + public List<String> getDeploymentDirs() { + return deploymentDirs; + } + + public void setDeploymentDirs(List<String> deploymentDirs) { + this.deploymentDirs = deploymentDirs; + } + + public void addDeploymentDir(String dir){ + deploymentDirs.add(dir); + } + + public void addPortMapping(PortMapping mapping){ + portMappings.add(mapping); + } + + public void addAppType(AppType type){ + appTypeMappings.add(type); + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public boolean isMultiTenant() { + return multiTenant; + } + + public void setMultiTenant(boolean multiTenant) { + this.multiTenant = multiTenant; + } + + public String getBaseDir() { + return baseDir; + } + + public void setBaseDir(String baseDir) { + this.baseDir = baseDir; + } + + public List<PortMapping> getPortMappings() { + return portMappings; + } + + public void setPortMappings(List<PortMapping> portMappings) { + this.portMappings = portMappings; + } + + public List<AppType> getAppTypeMappings() { + return appTypeMappings; + } + + public void setAppTypeMappings(List<AppType> appTypeMappings) { + this.appTypeMappings = appTypeMappings; + } + + public Map<String, IaasProvider> getPartitionToIaasProvider() { + return partitionToIaasProvider; + } + + public void setPartitionToIaasProvider(Map<String, IaasProvider> partitionToIaasProvider) { + this.partitionToIaasProvider = partitionToIaasProvider; + } + + public LoadbalancerConfig getLbConfig() { + return lbConfig; + } + + public void setLbConfig(LoadbalancerConfig lbConfig) { + this.lbConfig = lbConfig; + } + + public String getDefaultAutoscalingPolicy() { + return defaultAutoscalingPolicy; + } + + public void setDefaultAutoscalingPolicy(String defaultAutoscalingPolicy) { + this.defaultAutoscalingPolicy = defaultAutoscalingPolicy; + } + + /** + * @return the persistence + */ + public Persistence getPersistence() { + return persistence; + } + + /** + * @param persistence the peristanceMappings to set + */ + public void setPersistence(Persistence persistence) { + this.persistence = persistence; + } + + public String getDefaultDeploymentPolicy() { + return defaultDeploymentPolicy; + } + + public void setDefaultDeploymentPolicy(String defaultDeploymentPolicy) { + this.defaultDeploymentPolicy = defaultDeploymentPolicy; + } + + public String getServiceGroup() { + return serviceGroup; + } + + public void setServiceGroup(String serviceGroup) { + this.serviceGroup = serviceGroup; + } + + public Container getContainer() { + return container; + } + + public void setContainer(Container container) { + this.container = container; + } + + public String getDeployerType() { + return deployerType; + } + + public void setDeployerType(String deployerType) { + this.deployerType = deployerType; + } + + + public String[] getExportingProperties() { + return exportingProperties; + } + + public void setExportingProperties(String[] exportingProperties) { + this.exportingProperties = exportingProperties; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java new file mode 100644 index 0000000..2513350 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java @@ -0,0 +1,317 @@ +/* + * 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.domain; + +import java.io.Serializable; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; + +/** + * This class is used as the pojo for supporting the service at CC, + * which is called by the Rest API in SM to deploy a cartridge definition + */ +public class CartridgeConfig implements Serializable { + + private static final long serialVersionUID = 3455721779991902731L; + + private String type; + + private String hostName; + + private String provider; + + private String displayName; + + private String description; + + private String version; + + private boolean multiTenant; + + private boolean isPublic; + + private String baseDir; + + private String[] deploymentDirs; + + private PortMapping[] portMappings; + + private Persistence persistence; + + private String defaultAutoscalingPolicy; + + private String defaultDeploymentPolicy; + + private Properties properties; + + private IaasConfig[] iaasConfigs; + + private LoadbalancerConfig lbConfig; + + private String serviceGroup; + + private Container container; + private String[] exportingProperties; + + private String deployerType; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public boolean isMultiTenant() { + return multiTenant; + } + + public void setMultiTenant(boolean multiTenant) { + this.multiTenant = multiTenant; + } + + public boolean getIsPublic() { + return isPublic; + } + + public void setisPublic(boolean isPublic) { + this.isPublic = isPublic; + } + + public String getBaseDir() { + return baseDir; + } + + public void setBaseDir(String baseDir) { + this.baseDir = baseDir; + } + + public String[] getDeploymentDirs() { + return deploymentDirs; + } + + public void setDeploymentDirs(String[] deploymentDirs) { + this.deploymentDirs = ArrayUtils.clone(deploymentDirs); + } + + public PortMapping[] getPortMappings() { + return portMappings; + } + + public void setPortMappings(PortMapping[] portMappings) { + this.portMappings = ArrayUtils.clone(portMappings); + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + public IaasConfig[] getIaasConfigs() { + return iaasConfigs; + } + + public void setIaasConfigs(IaasConfig[] iaasConfigs) { + this.iaasConfigs = ArrayUtils.clone(iaasConfigs); + } + + public String toString () { + + return "Type: " + type + ", Provider: " + provider + ", Host: " + hostName + ", Display Name: " + displayName + + ", Description: " + description + ", Version: " + version + ", Multitenant " + multiTenant + ", IsPublic " + isPublic + + "\n Deployment: " + getDeploymentDetails() + "\n PortMapping: " + getPortMappingDetails() + + "\n IaaS: " + getIaasConfigDetails() + "\n Properties: " + getPropertyDetails(); + } + + private String getDeploymentDetails () { + + StringBuilder deploymentDetailBuilder = new StringBuilder(); + deploymentDetailBuilder.append("Base direcotry: " + getBaseDir()); + if(deploymentDirs != null) { + if(deploymentDirs.length > 0) { + deploymentDetailBuilder.append(" Direcotries: "); + for (String directory : deploymentDirs) { + deploymentDetailBuilder.append(directory + " | "); + } + } + } + + return deploymentDetailBuilder.toString(); + } + + private String getPortMappingDetails () { + + StringBuilder portMappingDetailBuilder = new StringBuilder(); + if(portMappings != null) { + if(portMappings.length > 0) { + for (PortMapping portMapping : portMappings) { + portMappingDetailBuilder.append(portMapping.toString() + " | "); + } + } + } + return portMappingDetailBuilder.toString(); + } + + private String getIaasConfigDetails () { + + StringBuilder iaasConfigDetailBuilder = new StringBuilder(); + if(iaasConfigs != null) { + if(iaasConfigs.length > 0) { + for (IaasConfig iaasConfig : iaasConfigs) { + iaasConfigDetailBuilder.append(iaasConfig.toString() + " | "); + } + } + } + return iaasConfigDetailBuilder.toString(); + } + + private String getPropertyDetails () { + + StringBuilder propertyDetailBuilder = new StringBuilder(); + if(properties != null) { + Property[] propertyArray = properties.getProperties(); + if (propertyArray.length > 0) { + for (Property property : propertyArray) { + propertyDetailBuilder.append(property.toString() + " | "); + } + } + } + return propertyDetailBuilder.toString(); + } + + public LoadbalancerConfig getLbConfig() { + return lbConfig; + } + + public void setLbConfig(LoadbalancerConfig lbConfig) { + this.lbConfig = lbConfig; + } + + public String getDefaultAutoscalingPolicy() { + return defaultAutoscalingPolicy; + } + + public void setDefaultAutoscalingPolicy(String defaultAutoscalingPolicy) { + this.defaultAutoscalingPolicy = defaultAutoscalingPolicy; + } + + public String getDefaultDeploymentPolicy() { + return defaultDeploymentPolicy; + } + + public void setDefaultDeploymentPolicy(String defaultDeploymentPolicy) { + this.defaultDeploymentPolicy = defaultDeploymentPolicy; + } + + /** + * @return the persistence + */ + public Persistence getPersistence() { + return persistence; + } + + /** + * @param persistence the persistanceMappings to set + */ + public void setPersistence(Persistence persistence) { + this.persistence = persistence; + } + + public String getServiceGroup() { + return serviceGroup; + } + + public void setServiceGroup(String serviceGroup) { + this.serviceGroup = serviceGroup; + } + + + public String[] getExportingProperties() { + return exportingProperties; + } + + public void setExportingProperties(String[] exportingProperties) { + this.exportingProperties = exportingProperties; + } + + public Container getContainer() { + return container; + } + + public void setContainer(Container container) { + this.container = container; + } + + public String getDeployerType() { + return deployerType; + } + + public void setDeployerType(String deployerType) { + this.deployerType = deployerType; + } + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java new file mode 100644 index 0000000..e35f357 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java @@ -0,0 +1,232 @@ +/* + * 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.domain; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Property; + +/** + * Holds useful information for externals, regarding a Cartridge. + */ +public class CartridgeInfo { + + private String type; + + private String hostName; + + private String displayName; + + private String description; + + private String[] deploymentDirs; + + private PortMapping[] portMappings; + + private AppType[] appTypes; + + private String provider; + + private String version; + + private boolean multiTenant; + + private boolean isPublic; + + private String baseDir; + + private Property[] properties; + + private String defaultAutoscalingPolicy; + + private String defaultDeploymentPolicy; + + private LoadbalancerConfig lbConfig; + + private Persistence persistence; + + private String serviceGroup; + + public CartridgeInfo(){ + + } + + public CartridgeInfo(String type, String host, String desc, List<String> deploymentDirs, String provider) { + this.type = type; + this.hostName = host; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public String[] getDeploymentDirs() { + return deploymentDirs; + } + + public void setDeploymentDirs(List<String> deploymentDirsList) { + if(deploymentDirsList == null){ + deploymentDirsList = new ArrayList<String>(); + } + this.deploymentDirs = new String[deploymentDirsList.size()]; + + deploymentDirsList.toArray(deploymentDirs); + + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public boolean isMultiTenant() { + return multiTenant; + } + + public void setMultiTenant(boolean multiTenant) { + this.multiTenant = multiTenant; + } + + public boolean getIsPublic() { + return isPublic; + } + + public void setIsPublic(boolean isPublic) { + this.isPublic = isPublic; + } + + public String getBaseDir() { + return baseDir; + } + + public void setBaseDir(String baseDir) { + this.baseDir = baseDir; + } + + public PortMapping[] getPortMappings() { + return portMappings; + } + + public void setPortMappings(PortMapping[] portMappings) { + this.portMappings = ArrayUtils.clone(portMappings); + } + + public AppType[] getAppTypes() { + return appTypes; + } + + public void setAppTypes(AppType[] appTypes) { + this.appTypes = ArrayUtils.clone(appTypes); + } + + public Property[] getProperties() { + return properties; + } + + public void setProperties(Property[] properties) { + this.properties = ArrayUtils.clone(properties); + } + + public String getDefaultAutoscalingPolicy() { + return defaultAutoscalingPolicy; + } + + public void setDefaultAutoscalingPolicy(String defaultAutoscalingPolicy) { + this.defaultAutoscalingPolicy = defaultAutoscalingPolicy; + } + + public LoadbalancerConfig getLbConfig() { + return lbConfig; + } + + public void setLbConfig(LoadbalancerConfig lbConfig) { + this.lbConfig = lbConfig; + } + + public String getDefaultDeploymentPolicy() { + return defaultDeploymentPolicy; + } + + public void setDefaultDeploymentPolicy(String defaultDeploymentPolicy) { + this.defaultDeploymentPolicy = defaultDeploymentPolicy; + } + + /** + * @return the persistence + */ + public Persistence getPersistence() { + return persistence; + } + + /** + * @param persistence the persistanceMappings to set + */ + public void setPersistence(Persistence persistence) { + this.persistence = persistence; + } + + public String getServiceGroup() { + return serviceGroup; + } + + public void setServiceGroup(String serviceGroup) { + this.serviceGroup = serviceGroup; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInstanceData.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInstanceData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInstanceData.java new file mode 100644 index 0000000..695d4bd --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInstanceData.java @@ -0,0 +1,120 @@ +/* + * 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.domain; + +import org.jclouds.compute.domain.NodeMetadata; + +/** + * This class holds the data to be published to BAM. + */ +public class CartridgeInstanceData { + + // Cartridge type + private String type; + + private String nodeId; + + private String domain; + + private String iaas; + + private String status; + + private String tenantRange; + + private String alias; + + private boolean isMultiTenant; + + private NodeMetadata metaData; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getNodeId() { + return nodeId; + } + + public void setNodeId(String nodeId) { + this.nodeId = nodeId; + } + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getIaas() { + return iaas; + } + + public void setIaas(String iaas) { + this.iaas = iaas; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public NodeMetadata getMetaData() { + return metaData; + } + + public void setMetaData(NodeMetadata metaData) { + this.metaData = metaData; + } + + public String getTenantRange() { + return tenantRange; + } + + public void setTenantRange(String tenantRange) { + this.tenantRange = tenantRange; + } + + public boolean isMultiTenant() { + return isMultiTenant; + } + + public void setMultiTenant(boolean isMultiTenant) { + this.isMultiTenant = isMultiTenant; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ClusterContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ClusterContext.java new file mode 100644 index 0000000..06e48cc --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ClusterContext.java @@ -0,0 +1,132 @@ +/* + * 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.domain; + +import java.io.Serializable; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Properties; + +/** + * Holds runtime data of a Cluster. + * + * + */ +public class ClusterContext implements Serializable{ + + private static final long serialVersionUID = 4830667953031229223L; + // cluster id + private String clusterId; + // cartridge type + private String cartridgeType; + // payload as a String + private String payload; + private String hostName; + private boolean isLbCluster; + private boolean isVolumeRequired; + private Volume[] volumes; + // timeout in milliseconds - this would be the per member time that CC waits before forcefully terminate instances on an unregistration. + private long timeoutInMillis; + private Properties properties; + + public ClusterContext(String clusterId, String cartridgeType, String payload, String hostName, + boolean isLbCluster, Properties properties) { + this.clusterId = clusterId; + this.cartridgeType = cartridgeType; + this.payload = payload; + this.setHostName(hostName); + this.isLbCluster = isLbCluster; + this.setProperties(properties); + } + + 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 getPayload() { + return payload; + } + public void setPayload(String payload) { + this.payload = payload; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public boolean isLbCluster() { + return isLbCluster; + } + + public void setLbCluster(boolean isLbCluster) { + this.isLbCluster = isLbCluster; + } + + public boolean isVolumeRequired() { + return isVolumeRequired; + } + + public void setVolumeRequired(boolean isVolumeRequired) { + this.isVolumeRequired = isVolumeRequired; + } + + public long getTimeoutInMillis() { + return timeoutInMillis; + } + + public void setTimeoutInMillis(long timeoutInMillis) { + this.timeoutInMillis = timeoutInMillis; + } + + public Volume[] getVolumes() { + return volumes; + } + + public void setVolumes(Volume[] volumes) { + this.volumes = ArrayUtils.clone(volumes); + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + /*public void addProperty(String key, int value) { + this.properties.put(key, value); + } + + public void addProperty(String key, String value) { + this.properties.put(key, value); + }*/ +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CompositeApplicationDefinition.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CompositeApplicationDefinition.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CompositeApplicationDefinition.java new file mode 100644 index 0000000..62d46ce --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CompositeApplicationDefinition.java @@ -0,0 +1,38 @@ +package org.apache.stratos.cloud.controller.domain; + +import java.io.Serializable; + +public class CompositeApplicationDefinition implements Serializable { + + private static final long serialVersionUID = 1L; + private String applicationId; + private String alias; + private ConfigGroup[] components; + private ConfigCartridge [] cartridges; + public ConfigCartridge[] getCartridges() { + return cartridges; + } + public void setCartridges(ConfigCartridge[] cartridges) { + this.cartridges = cartridges; + } + public String getApplicationId() { + return applicationId; + } + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + public String getAlias() { + return alias; + } + public void setAlias(String alias) { + this.alias = alias; + } + public ConfigGroup[] getComponents() { + return components; + } + public void setComponents(ConfigGroup[] components) { + this.components = components; + } + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigCartridge.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigCartridge.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigCartridge.java new file mode 100644 index 0000000..d69b90b --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigCartridge.java @@ -0,0 +1,17 @@ +package org.apache.stratos.cloud.controller.domain; + +import java.io.Serializable; + + +public class ConfigCartridge implements Serializable { + private String alias; + private static final long serialVersionUID = 1L; + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencies.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencies.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencies.java new file mode 100644 index 0000000..e3abad4 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencies.java @@ -0,0 +1,26 @@ +package org.apache.stratos.cloud.controller.domain; + +import java.io.Serializable; + + +public class ConfigDependencies implements Serializable { + private ConfigDependencyPair[] startup_order; + private String kill_behavior; + private static final long serialVersionUID = 1L; + + public ConfigDependencyPair[] getStartup_order() { + return startup_order; + } + public void setStartup_order(ConfigDependencyPair[] startup_order) { + this.startup_order = startup_order; + } + public String getKill_behavior() { + return kill_behavior; + } + public void setKill_behavior(String kill_behavior) { + this.kill_behavior = kill_behavior; + } + + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencyPair.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencyPair.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencyPair.java new file mode 100644 index 0000000..6a8c1d0 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigDependencyPair.java @@ -0,0 +1,29 @@ +package org.apache.stratos.cloud.controller.domain; + +import java.io.Serializable; + +public class ConfigDependencyPair implements Serializable { + private String key; + private String value; + private static final long serialVersionUID = 1L; + + public ConfigDependencyPair() {} + + public ConfigDependencyPair(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigGroup.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigGroup.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigGroup.java new file mode 100644 index 0000000..3d827f7 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ConfigGroup.java @@ -0,0 +1,33 @@ +package org.apache.stratos.cloud.controller.domain; + +import java.io.Serializable; + + +public class ConfigGroup implements Serializable { + private String alias; + private String[] subscribables; + private ConfigDependencies dependencies; + private static final long serialVersionUID = 1L; + + public String getAlias() { + return alias; + } + public void setAlias(String alias) { + this.alias = alias; + } + public String[] getSubscribables() { + return subscribables; + } + public void setSubscribables(String[] subscribables) { + this.subscribables = subscribables; + } + public ConfigDependencies getDependencies() { + return dependencies; + } + public void setDependencies(ConfigDependencies dependencies) { + this.dependencies = dependencies; + } + + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Container.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Container.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Container.java new file mode 100644 index 0000000..5cb8708 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Container.java @@ -0,0 +1,59 @@ +/* + * 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.domain; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class Container implements Serializable { + + private static final long serialVersionUID = 2232204459987683768L; + + private String imageName; + + private String dockerFileRepo; + + private Map<String, String> properties = new HashMap<String, String>(); + + public String getImageName() { + return imageName; + } + + public void setImageName(String imageName) { + this.imageName = imageName; + } + + public String getDockerFileRepo() { + return dockerFileRepo; + } + + public void setDockerFileRepo(String dockerFileRepo) { + this.dockerFileRepo = dockerFileRepo; + } + + public Map<String, String> getProperties() { + return properties; + } + + public void setProperties(Map<String, String> properties) { + this.properties = properties; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ContainerClusterContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ContainerClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ContainerClusterContext.java new file mode 100644 index 0000000..de7dd84 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/ContainerClusterContext.java @@ -0,0 +1,89 @@ +/* + * 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.domain; + +import org.apache.stratos.common.Properties; + +import java.io.Serializable; + +/** + * Holds information about a container cluster to be started. + * + */ +public class ContainerClusterContext implements Serializable { + + private static final long serialVersionUID = -388327475844701869L; + // cluster id this Pod belongs to + private String clusterId; + // properties + private Properties properties; + + public ContainerClusterContext() { + } + + public ContainerClusterContext(String clusterId) { + this.clusterId = clusterId; + } + + public String getClusterId() { + return clusterId; + } + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((clusterId == null) ? 0 : clusterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ContainerClusterContext other = (ContainerClusterContext) obj; + if (clusterId == null) { + if (other.clusterId != null) + return false; + } else if (!clusterId.equals(other.clusterId)) + return false; + return true; + } + + @Override + public String toString() { + return "ContainerClusterContext [clusterId=" + clusterId + ", properties=" + properties + + "]"; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/DataPublisherConfig.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/DataPublisherConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/DataPublisherConfig.java new file mode 100644 index 0000000..735dbdc --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/DataPublisherConfig.java @@ -0,0 +1,85 @@ +/* + * 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.domain; + +import java.io.Serializable; + +import org.apache.stratos.cloud.controller.util.CloudControllerConstants; + +/** + * + * + */ +public class DataPublisherConfig implements Serializable{ + + private static final long serialVersionUID = -2097472019584151205L; + private String bamUsername = CloudControllerConstants.DEFAULT_BAM_SERVER_USER_NAME; + private String bamPassword = CloudControllerConstants.DEFAULT_BAM_SERVER_PASSWORD; + private String dataPublisherCron = CloudControllerConstants.PUB_CRON_EXPRESSION; + private String cassandraConnUrl = CloudControllerConstants.DEFAULT_CASSANDRA_URL; + private String cassandraUser = CloudControllerConstants.DEFAULT_CASSANDRA_USER; + private String cassandraPassword = CloudControllerConstants.DEFAULT_CASSANDRA_PASSWORD; + + public String getBamUsername() { + return bamUsername; + } + + public void setBamUsername(String bamUsername) { + this.bamUsername = bamUsername; + } + + public String getBamPassword() { + return bamPassword; + } + + public void setBamPassword(String bamPassword) { + this.bamPassword = bamPassword; + } + + public String getDataPublisherCron() { + return dataPublisherCron; + } + + public void setDataPublisherCron(String dataPublisherCron) { + this.dataPublisherCron = dataPublisherCron; + } + public String getCassandraConnUrl() { + return cassandraConnUrl; + } + + public void setCassandraConnUrl(String cassandraHostAddr) { + this.cassandraConnUrl = cassandraHostAddr; + } + + public String getCassandraUser() { + return cassandraUser; + } + + public void setCassandraUser(String cassandraUser) { + this.cassandraUser = cassandraUser; + } + + public String getCassandraPassword() { + return cassandraPassword; + } + + public void setCassandraPassword(String cassandraPassword) { + this.cassandraPassword = cassandraPassword; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Dependencies.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Dependencies.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Dependencies.java new file mode 100644 index 0000000..a04fb91 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Dependencies.java @@ -0,0 +1,48 @@ +/* + * 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.domain; + +import java.io.Serializable; +import java.util.List; + +public class Dependencies implements Serializable { + + private static final long serialVersionUID = 4187267350546153680L; + + private String [] startupOrders; + + private String killBehaviour; + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } + + public String[] getStartupOrders() { + return startupOrders; + } + + public void setStartupOrders(String[] startupOrders) { + this.startupOrders = startupOrders; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasConfig.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasConfig.java new file mode 100644 index 0000000..6725f29 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasConfig.java @@ -0,0 +1,174 @@ +/* + * 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.domain; + +import java.io.Serializable; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; + +/** + * This class is used to support <link>CartridgeConfig</link> + * class for the Rest API + */ +public class IaasConfig implements Serializable { + + + private static final long serialVersionUID = 3329046207651171707L; + + private String type; + + private String className; + + private String name; + + private String provider, identity, credential; + + private String imageId; + + private int maxInstanceLimit; + + private Properties properties; + + private NetworkInterfaces networkInterfaces; + + private byte[] payload; + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + public String getCredential() { + return credential; + } + + public void setCredential(String credential) { + this.credential = credential; + } + + public byte[] getPayload() { + return payload; + } + + public void setPayload(byte[] payload) { + this.payload = ArrayUtils.clone(payload); + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getImageId() { + return imageId; + } + + public void setImageId(String imageId) { + this.imageId = imageId; + } + + public int getMaxInstanceLimit() { + return maxInstanceLimit; + } + + public void setMaxInstanceLimit(int maxInstanceLimit) { + this.maxInstanceLimit = maxInstanceLimit; + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + public String toString () { + + return " [ Type: " + type + ", Name: " + name + ", Class Name: " + className + ", Image Id: " + imageId + + ", Max Instance Limit: " + maxInstanceLimit + ", Provider: " + provider + ", Identity: " + identity + + ", Credentials: " + credential + ", Properties: " + getIaasProperties() + " ] "; + } + + private String getIaasProperties () { + + StringBuilder iaasPropertyBuilder = new StringBuilder(); + if (properties != null) { + Property[] propertyArray = properties.getProperties(); + if(propertyArray.length > 0) { + for (Property property : propertyArray) { + iaasPropertyBuilder.append(property.toString() + " | "); + } + } + } + return iaasPropertyBuilder.toString(); + } + + /** + * @return the networkInterfaces + */ + public NetworkInterfaces getNetworkInterfaces() { + return networkInterfaces; + } + + /** + * @param networkInterfaces the networkInterfaces to set + */ + public void setNetworkInterfaces(NetworkInterfaces networkInterfaces) { + this.networkInterfaces = networkInterfaces; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasProvider.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasProvider.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasProvider.java new file mode 100644 index 0000000..3cf25fb --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/IaasProvider.java @@ -0,0 +1,265 @@ +/* + * 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.domain; + +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.cloud.controller.exception.InvalidIaasProviderException; +import org.apache.stratos.cloud.controller.iaas.Iaas; +import org.apache.stratos.cloud.controller.util.CloudControllerUtil; +import org.jclouds.compute.ComputeService; +import org.jclouds.compute.domain.Template; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +/** + * This is the basic data structure which holds an IaaS specific details. + * NOTE: If you add a new attribute, please assign it in the constructor too. + */ +public class IaasProvider implements Serializable{ + + private static final long serialVersionUID = -940288190885166118L; + + /** + * Type of the IaasProvider. + */ + private String type; + + + /** + * Fully qualified class name of an implementation of {@link org.apache.stratos.cloud.controller.iaas.Iaas} + */ + private String className; + + /** + * human description of this IaaS provider + */ + private String name; + + /** + * Property map of this IaaS provider. + */ + private Map<String, String> properties = new HashMap<String, String>(); + + /** + * Network Interfaces Configuration + */ + private NetworkInterface[] networkInterfaces; + + /** + * Image identifier. + */ + private String image; + + private String provider, identity, credential; + + private transient ComputeService computeService; + + private transient Template template; + + private byte[] payload; + + /** + * Corresponding {@link org.apache.stratos.cloud.controller.iaas.Iaas} implementation + */ + private transient Iaas iaas; + + public IaasProvider(){} + + public IaasProvider(IaasProvider anIaasProvider){ + this.type = anIaasProvider.getType(); + this.name = anIaasProvider.getName(); + this.className = anIaasProvider.getClassName(); + this.properties = new HashMap<String,String>(anIaasProvider.getProperties()); + this.networkInterfaces = anIaasProvider.getNetworkInterfaces(); + this.image = anIaasProvider.getImage(); + this.provider = anIaasProvider.getProvider(); + this.identity = anIaasProvider.getIdentity(); + this.credential = anIaasProvider.getCredential(); + this.payload = anIaasProvider.getPayload(); + } + + public String getType() { + return type; + } + + public void setType(String id) { + this.type = id; + } + + public String getProperty(String key) { + return properties.get(key); + } + + public Map<String, String> getProperties() { + return properties; + } + + public void addProperty(String key, String val) { + if (key != null && val != null) { + properties.put(key, val); + } + } + + public void setProperty(String key, String value) { + + if(key != null && value != null){ + properties.put(key, value); + } + } + + public void setProperties(Map<String, String> properties) { + this.properties = properties; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + public String getCredential() { + return credential; + } + + public void setCredential(String credential) { + this.credential = credential; + } + + public ComputeService getComputeService() { + return computeService; + } + + public void setComputeService(ComputeService computeService) { + this.computeService = computeService; + } + + public Template getTemplate() { + return template; + } + + public void setTemplate(Template template) { + this.template = template; + } + + + + public boolean equals(Object o) { + if(o instanceof IaasProvider){ + return ((IaasProvider) o).getType().equals(this.getType()); + } + + return false; + } + + public int hashCode() { + return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers + append(type). + toHashCode(); + } + + public IaasProvider copy(){ + return new IaasProvider(this); + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Iaas getIaas() { + if (iaas == null) { + try { + iaas = CloudControllerUtil.getIaas(this); + } catch (InvalidIaasProviderException e) { + return null; + } + } + return iaas; + } + + public void setIaas(Iaas iaas) { + this.iaas = iaas; + } + + public void reset(){ +// nodeIds = new ArrayList<String>(); +// nodes = new HashMap<String, NodeMetadata>(); +// toBeRemovedNodeIds = new ArrayList<String>(); + } + + public byte[] getPayload() { + return payload; + } + + public void setPayload(byte[] payload) { + this.payload = ArrayUtils.clone(payload); + } + + /** + * @return the networkInterfaces + */ + public NetworkInterface[] getNetworkInterfaces() { + return networkInterfaces; + } + + /** + * @param networkInterfaces the networkInterfaces to set + */ + public void setNetworkInterfaces(NetworkInterface[] networkInterfaces) { + this.networkInterfaces = ArrayUtils.clone(networkInterfaces); + } + + @Override + public String toString() { + return "IaasProvider [type=" + type + ", name=" + name + ", image=" + image + + ", provider=" + provider + "]"; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/KubernetesClusterContext.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/KubernetesClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/KubernetesClusterContext.java new file mode 100644 index 0000000..1f19271 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/KubernetesClusterContext.java @@ -0,0 +1,187 @@ +/* + * 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.domain; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.kubernetes.client.KubernetesApiClient; + +/** + * Holds information about a Kubernetes Cluster. + * + * + */ +public class KubernetesClusterContext implements Serializable { + + private static final long serialVersionUID = -802025758806195791L; + private static final Log log = LogFactory.getLog(KubernetesClusterContext.class); + + // id of the Kubernetes cluster + private String kubernetesClusterId; + // available host port range, delimited by a hyphen + private String hostPortRange; + // kubernetes master ip + private String masterIp; + // available list of ports + private List<Integer> availableHostPorts; + // kubernetes client API instance + private transient KubernetesApiClient kubApi; + + public KubernetesClusterContext(String id, String portRange, String masterIp) { + availableHostPorts = new ArrayList<Integer>(); + this.kubernetesClusterId = id; + this.hostPortRange = portRange; + this.masterIp = masterIp; + this.setKubApi(new KubernetesApiClient(getEndpoint(masterIp))); + + } + + private String getEndpoint(String ip) { + return "http://"+ip+":8080/api/v1beta1/"; + } + + public String getKubernetesClusterId() { + return kubernetesClusterId; + } + public void setKubernetesClusterId(String kubernetesClusterId) { + this.kubernetesClusterId = kubernetesClusterId; + } + + public String getHostPortRange() { + return hostPortRange; + } + + public void setHostPortRange(String hostPortRange) { + this.hostPortRange = hostPortRange; + } + + public List<Integer> getAvailableHostPorts() { + return availableHostPorts; + } + + public void setAvailableHostPorts(List<Integer> availableHostPorts) { + this.availableHostPorts = availableHostPorts; + } + + private int[] portBoundaries() { + String[] portStrings = hostPortRange.split("-"); + int[] portInts = new int[2]; + portInts[0] = Integer.parseInt(portStrings[0]); + portInts[1] = Integer.parseInt(portStrings[1]); + return portInts; + } + + public int getAnAvailableHostPort() { + int[] ports = {4000, 5000}; + if (availableHostPorts.isEmpty()) { + try { + + ports = portBoundaries(); + } catch (Exception ignore) { + // on an exception, we use the default range + log.warn("Unable to find a port range, hence using the default. [4000-5000]" + + " Exception"); + } + + // populate the ports + populatePorts(ports[0], ports[1]); + } + + return availableHostPorts.remove(0); + } + + public void deallocateHostPort (int port) { + if (!availableHostPorts.contains(port)) { + availableHostPorts.add(port); + } + } + + private void populatePorts(int i, int j) { + + for (int x = i; x < j; x++) { + availableHostPorts.add(x); + } + } + + public String getMasterIp() { + return masterIp; + } + + public void setMasterIp(String masterIp) { + this.masterIp = masterIp; + } + + public KubernetesApiClient getKubApi() { + if (kubApi == null) { + kubApi = new KubernetesApiClient(getEndpoint(masterIp)); + } + return kubApi; + } + + public void setKubApi(KubernetesApiClient kubApi) { + this.kubApi = kubApi; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((hostPortRange == null) ? 0 : hostPortRange.hashCode()); + result = prime + * result + + ((kubernetesClusterId == null) ? 0 : kubernetesClusterId + .hashCode()); + result = prime * result + + ((masterIp == null) ? 0 : masterIp.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + KubernetesClusterContext other = (KubernetesClusterContext) obj; + if (hostPortRange == null) { + if (other.hostPortRange != null) + return false; + } else if (!hostPortRange.equals(other.hostPortRange)) + return false; + if (kubernetesClusterId == null) { + if (other.kubernetesClusterId != null) + return false; + } else if (!kubernetesClusterId.equals(other.kubernetesClusterId)) + return false; + if (masterIp == null) { + if (other.masterIp != null) + return false; + } else if (!masterIp.equals(other.masterIp)) + return false; + return true; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/8c359dc1/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/LoadbalancerConfig.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/LoadbalancerConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/LoadbalancerConfig.java new file mode 100644 index 0000000..1e780cf --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/LoadbalancerConfig.java @@ -0,0 +1,73 @@ +/* + * 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.domain; + +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; + +import java.io.Serializable; + +/** + * This class is used to support <link>CartridgeConfig</link> + * class for the Rest API + */ +public class LoadbalancerConfig implements Serializable { + + private static final long serialVersionUID = 289225330995632449L; + + private String type; + + private Properties properties; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } + + public String toString () { + + return " [ Type: " + type + ", Properties: " + getIaasProperties() + " ] "; + } + + private String getIaasProperties () { + + StringBuilder iaasPropertyBuilder = new StringBuilder(); + if (properties != null) { + Property[] propertyArray = properties.getProperties(); + if(propertyArray.length > 0) { + for (Property property : propertyArray) { + iaasPropertyBuilder.append(property.toString() + " | "); + } + } + } + return iaasPropertyBuilder.toString(); + } +}
