You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/01/04 05:52:09 UTC
[01/13] stratos git commit: Refining stratos manager component and
removing unused code
Repository: stratos
Updated Branches:
refs/heads/master 8013b2fd9 -> 79c69e775
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index 840d818..fd904a8 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -23,9 +23,11 @@ import org.apache.axis2.context.ConfigurationContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.stub.*;
+import org.apache.stratos.autoscaler.stub.AutoScalerServiceApplicationDefinitionExceptionException;
+import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException;
import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
+import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
import org.apache.stratos.cloud.controller.stub.*;
import org.apache.stratos.cloud.controller.stub.domain.CartridgeConfig;
import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
@@ -33,53 +35,40 @@ import org.apache.stratos.cloud.controller.stub.domain.Persistence;
import org.apache.stratos.cloud.controller.stub.domain.Volume;
import org.apache.stratos.common.beans.ApplicationBean;
import org.apache.stratos.common.beans.GroupBean;
+import org.apache.stratos.common.beans.autoscaler.partition.ApplicationLevelNetworkPartition;
+import org.apache.stratos.common.beans.autoscaler.policy.autoscale.AutoscalePolicy;
+import org.apache.stratos.common.beans.cartridge.definition.CartridgeDefinitionBean;
+import org.apache.stratos.common.beans.cartridge.definition.PersistenceBean;
+import org.apache.stratos.common.beans.cartridge.definition.VolumeBean;
+import org.apache.stratos.common.beans.kubernetes.KubernetesCluster;
+import org.apache.stratos.common.beans.kubernetes.KubernetesHost;
+import org.apache.stratos.common.beans.kubernetes.KubernetesMaster;
+import org.apache.stratos.common.beans.repositoryNotificationInfoBean.Payload;
import org.apache.stratos.common.beans.topology.ApplicationInfoBean;
import org.apache.stratos.common.beans.topology.ApplicationInstanceBean;
import org.apache.stratos.common.beans.topology.GroupInstanceBean;
+import org.apache.stratos.manager.artifact.distribution.coordinator.RepositoryNotifier;
import org.apache.stratos.manager.client.AutoscalerServiceClient;
import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
-import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager;
-import org.apache.stratos.manager.dto.Cartridge;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.grouping.manager.ServiceGroupingManager;
-import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
-import org.apache.stratos.manager.repository.RepositoryNotification;
-import org.apache.stratos.manager.subscription.ApplicationSubscription;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.DataCartridgeSubscription;
-import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
+import org.apache.stratos.manager.domain.ApplicationDefinition;
+import org.apache.stratos.manager.domain.ApplicationSubscription;
+import org.apache.stratos.manager.domain.ServiceGroupDefinition;
import org.apache.stratos.manager.utils.ApplicationManagementUtil;
import org.apache.stratos.manager.utils.CartridgeConstants;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.ClusterDataHolder;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager;
import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-//import org.apache.stratos.common.beans.ApplicationBean;
-//import org.apache.stratos.common.beans.GroupBean;
-import org.apache.stratos.common.beans.autoscaler.partition.ApplicationLevelNetworkPartition;
-import org.apache.stratos.common.beans.autoscaler.policy.autoscale.AutoscalePolicy;
-import org.apache.stratos.common.beans.cartridge.definition.CartridgeDefinitionBean;
-import org.apache.stratos.common.beans.cartridge.definition.PersistenceBean;
-import org.apache.stratos.common.beans.cartridge.definition.PropertyBean;
-import org.apache.stratos.common.beans.cartridge.definition.VolumeBean;
-import org.apache.stratos.common.beans.kubernetes.KubernetesCluster;
-import org.apache.stratos.common.beans.kubernetes.KubernetesHost;
-import org.apache.stratos.common.beans.kubernetes.KubernetesMaster;
-import org.apache.stratos.common.beans.repositoryNotificationInfoBean.Payload;
-import org.apache.stratos.rest.endpoint.util.converter.ObjectConverter;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
+import org.apache.stratos.rest.endpoint.util.converter.ObjectConverter;
import java.rmi.RemoteException;
import java.util.*;
import java.util.regex.Pattern;
+
public class StratosApiV41Utils {
public static final String IS_VOLUME_REQUIRED = "volume.required";
public static final String SHOULD_DELETE_VOLUME = "volume.delete.on.unsubscription";
@@ -90,110 +79,55 @@ public class StratosApiV41Utils {
public static final String APPLICATION_STATUS_DEPLOYED = "Deployed";
private static Log log = LogFactory.getLog(StratosApiV41Utils.class);
- private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager();
- private static ServiceGroupingManager serviceGropingManager = new ServiceGroupingManager();
- private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager();
// Util methods for cartridges
- public static void addCartridge(CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt,
- String userName, String tenantDomain) throws RestAPIException {
+ public static void addCartridge(CartridgeDefinitionBean cartridgeDefinition) throws RestAPIException {
- if(log.isDebugEnabled()) {
- log.debug(String.format("Adding cartridge: [cartridge-type] %s ", cartridgeDefinitionBean.getType()));
- }
- CartridgeConfig cartridgeConfig = ObjectConverter.convertCartridgeDefinitionBeanToStubCartridgeConfig(cartridgeDefinitionBean);
- if (cartridgeConfig == null) {
- throw new RestAPIException("Could not read cartridge definition, cartridge deployment failed");
- }
- if (StringUtils.isEmpty(cartridgeConfig.getCategory())) {
- throw new RestAPIException(String.format("Category is not specified %s , hence cartridge deployment failed",cartridgeConfig.getDisplayName()));
- }
try {
- CartridgeDeploymentManager.getDeploymentManager().deploy(cartridgeConfig);
- } catch (ADCException e) {
- throw new RestAPIException(e);
- }
- if(log.isDebugEnabled()) {
- log.debug(String.format("Successfully added cartridge: [cartridge-type] %s ", cartridgeDefinitionBean.getType()));
- }
- }
-
- public static void removeCartridge(String cartridgeType) throws RestAPIException {
-
- CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
- if (cloudControllerServiceClient != null) {
-
- CartridgeInfo cartridgeInfo = null;
- try {
- cartridgeInfo = cloudControllerServiceClient.getCartridgeInfo(cartridgeType);
- } catch (RemoteException e) {
- log.error(String.format("Could not find cartridge: [cartridge-type] %s ", cartridgeType));
- throw new RestAPIException(e);
-
- } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
- log.error(String.format("Could not find cartridge: [cartridge-type] %s " , cartridgeType));
- throw new RestAPIException(e);
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Adding cartridge: [cartridge-type] %s ", cartridgeDefinition.getType()));
}
- if (cartridgeInfo == null) {
- String errorMsg = String.format("Could not find cartridge: [cartridge-type] %s ", cartridgeType);
- log.error(errorMsg);
- throw new RestAPIException(errorMsg);
+ CartridgeConfig cartridgeConfig = ObjectConverter.convertCartridgeDefinitionBeanToStubCartridgeConfig(cartridgeDefinition);
+ if (cartridgeConfig == null) {
+ throw new RestAPIException("Could not read cartridge definition, cartridge deployment failed");
}
+ if (StringUtils.isEmpty(cartridgeConfig.getCategory())) {
+ throw new RestAPIException(String.format("Category is not specified in cartridge: [cartridge-type] %s",cartridgeConfig.getType()));
+ }
+ CloudControllerServiceClient cloudControllerServiceClient = CloudControllerServiceClient.getServiceClient();
+ cloudControllerServiceClient.addCartridge(cartridgeConfig);
- // check if the service is multi tenant.
- if (cartridgeInfo.getMultiTenant()) {
- // check if there are any deployed MT services. If so, should not allow to undeploy
- try {
- Service service = serviceDeploymentManager.getService(cartridgeType);
- if (service != null) {
- // not allowed to undeploy!
- String errorMsg =
- String.format("Multi tenant Service already exists for %s ,hence cannot undeploy",
- cartridgeType);
- log.error(errorMsg);
- throw new RestAPIException(errorMsg);
- } else {
- // can undeploy
- undeployCartridgeDefinition(cloudControllerServiceClient, cartridgeType);
- }
-
- } catch (ADCException e) {
- log.error(String.format("Error in getting MT Service details for type %s " , cartridgeType));
- throw new RestAPIException(e);
- }
-
- } else {
- // if not multi tenant, check if there are any existing Subscriptions
- Collection<CartridgeSubscription> cartridgeSubscriptions =
- cartridgeSubsciptionManager.getCartridgeSubscriptionsForType(cartridgeType);
- if (cartridgeSubscriptions != null && !cartridgeSubscriptions.isEmpty()) {
- // not allowed to undeploy!
- String errorMsg =String.format("Subscription exists for %s, cannot undeploy",cartridgeType);
- log.error(errorMsg);
- throw new RestAPIException(errorMsg);
- } else {
- // can undeploy
- undeployCartridgeDefinition(cloudControllerServiceClient, cartridgeType);
- }
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Successfully added cartridge: [cartridge-type] %s ", cartridgeDefinition.getType()));
}
+ } catch (Exception e) {
+ String msg = "Could not add cartridge";
+ log.error(msg, e);
+ throw new RestAPIException(msg);
}
}
- private static void undeployCartridgeDefinition(CloudControllerServiceClient cloudControllerServiceClient,
- String cartridgeType) throws RestAPIException {
+ public static void removeCartridge(String cartridgeType) throws RestAPIException {
try {
- cloudControllerServiceClient.removeCartridge(cartridgeType);
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Removing cartridge: [cartridge-type] %s ", cartridgeType));
+ }
- } catch (RemoteException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
+ CloudControllerServiceClient cloudControllerServiceClient = CloudControllerServiceClient.getServiceClient();
+ if(cloudControllerServiceClient.getCartridgeInfo(cartridgeType) == null) {
+ throw new RuntimeException("Cartridge not found: [cartridge-type] " + cartridgeType);
+ }
+ cloudControllerServiceClient.removeCartridge(cartridgeType);
- } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) {
- String msg = e.getFaultMessage().getInvalidCartridgeTypeException().getMessage();
+ if(log.isInfoEnabled()) {
+ log.info(String.format("Successfully removed cartridge: [cartridge-type] %s ", cartridgeType));
+ }
+ } catch (Exception e) {
+ String msg = "Could not remove cartridge";
log.error(msg, e);
- throw new RestAPIException(msg, e);
+ throw new RestAPIException(msg);
}
}
@@ -453,15 +387,8 @@ public class StratosApiV41Utils {
return list;
}
- private static boolean isAlreadySubscribed(String cartridgeType,
- int tenantId) {
-
- Collection<CartridgeSubscription> subscriptionList = CartridgeSubscriptionManager.isCartridgeSubscribed(tenantId, cartridgeType);
- if (subscriptionList == null || subscriptionList.isEmpty()) {
- return false;
- } else {
- return true;
- }
+ private static boolean isAlreadySubscribed(String cartridgeType, int tenantId) {
+ return false;
}
private static Pattern getSearchStringPattern(String searchString) {
@@ -496,26 +423,6 @@ public class StratosApiV41Utils {
return true;
}
- private static boolean cartridgeMatches(CartridgeInfo cartridgeInfo, CartridgeSubscription cartridgeSubscription, Pattern pattern) {
- if (pattern != null) {
- boolean matches = false;
- if (cartridgeInfo.getDisplayName() != null) {
- matches = pattern.matcher(cartridgeInfo.getDisplayName().toLowerCase()).find();
- }
- if (!matches && cartridgeInfo.getDescription() != null) {
- matches = pattern.matcher(cartridgeInfo.getDescription().toLowerCase()).find();
- }
- if (!matches && cartridgeSubscription.getType() != null) {
- matches = pattern.matcher(cartridgeSubscription.getType().toLowerCase()).find();
- }
- if (!matches && cartridgeSubscription.getAlias() != null) {
- matches = pattern.matcher(cartridgeSubscription.getAlias().toLowerCase()).find();
- }
- return matches;
- }
- return true;
- }
-
// Util methods to get the service clients
private static CloudControllerServiceClient getCloudControllerServiceClient() throws RestAPIException {
@@ -662,268 +569,235 @@ public class StratosApiV41Utils {
return ObjectConverter.convertStubApplicationLevelNetworkPartitionsToApplicationLevelNetworkPartitions(partitionGroups);
}
- // Util methods for services and subscriptions
+// public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenant(ConfigurationContext configurationContext) {
+//
+// Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
+// getTenantId(configurationContext), null);
+// ArrayList<org.apache.stratos.common.beans.topology.Cluster> clusters =
+// new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
+// for (Cluster cluster : clusterSet) {
+// clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
+// }
+// org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
+// new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
+// arrCluster = clusters.toArray(arrCluster);
+// return arrCluster;
+//
+// }
+
+// public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenantAndCartridgeType(ConfigurationContext configurationContext,
+// String cartridgeType) {
+//
+// Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
+// getTenantId(configurationContext), cartridgeType);
+// List<org.apache.stratos.common.beans.topology.Cluster> clusters =
+// new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
+// for (Cluster cluster : clusterSet) {
+// clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
+// }
+// org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
+// new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
+// arrCluster = clusters.toArray(arrCluster);
+// return arrCluster;
+//
+// }
- public static List<Cartridge> getSubscriptions(String cartridgeSearchString, String serviceGroup, ConfigurationContext configurationContext) throws RestAPIException {
- List<Cartridge> cartridges = new ArrayList<Cartridge>();
-
- if (log.isDebugEnabled()) {
- log.debug("Getting subscribed cartridges. Search String: " + cartridgeSearchString);
- }
+ // Util methods for repo actions
+ public static void getGitRepositoryNotification(Payload payload) throws RestAPIException {
try {
- Pattern searchPattern = getSearchStringPattern(cartridgeSearchString);
- Collection<CartridgeSubscription> subscriptions = CartridgeSubscriptionManager.getCartridgeSubscriptions(ApplicationManagementUtil.
- getTenantId(configurationContext), null);
+ RepositoryNotifier repoNotification = new RepositoryNotifier();
+ repoNotification.updateRepository(payload.getRepository().getUrl());
- if (subscriptions != null && !subscriptions.isEmpty()) {
+ } catch (Exception e) {
+ String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
+ log.error(msg, e);
+ throw new RestAPIException(msg, e);
+ }
+ }
- for (CartridgeSubscription subscription : subscriptions) {
+// public static void synchronizeRepository(CartridgeSubscription cartridgeSubscription) throws RestAPIException {
+// try {
+// RepositoryNotifier repoNotification = new RepositoryNotifier();
+// repoNotification.updateRepository(cartridgeSubscription);
+// } catch (Exception e) {
+// String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(msg, e);
+// }
+// }
- if (!cartridgeMatches(subscription.getCartridgeInfo(), subscription, searchPattern)) {
- continue;
- }
- Cartridge cartridge = getCartridgeFromSubscription(subscription);
- if (cartridge == null) {
- continue;
- }
- Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
- cartridge.getCartridgeAlias());
- String cartridgeStatus = "Inactive";
- int activeMemberCount = 0;
- if (cluster != null) {
- Collection<Member> members = cluster.getMembers();
- for (Member member : members) {
- if (member.isActive()) {
- cartridgeStatus = "Active";
- activeMemberCount++;
- }
- }
- }
- cartridge.setActiveInstances(activeMemberCount);
- cartridge.setStatus(cartridgeStatus);
+ // Util methods for service groups
+
+ public static void addServiceGroup(ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException {
+ try {
+ if (serviceGroupDefinition == null) {
+ throw new RuntimeException("Service Group definition is null");
+ }
+
+ // if any cartridges are specified in the group, they should be already deployed
+ if (serviceGroupDefinition.getCartridges() != null) {
- // Ignoring the LB cartridges since they are not shown to the user.
- if (cartridge.isLoadBalancer())
- continue;
- if (StringUtils.isNotEmpty(serviceGroup)) {
- if (cartridge.getServiceGroup() != null && serviceGroup.equals(cartridge.getServiceGroup())) {
- cartridges.add(cartridge);
- }
- } else {
- cartridges.add(cartridge);
- }
- }
- } else {
if (log.isDebugEnabled()) {
- log.debug("There are no subscribed cartridges");
+ log.debug("checking cartridges in service group " + serviceGroupDefinition.getName());
}
- }
- } catch (Exception e) {
- String msg = "Error while getting subscribed cartridges. Cause: " + e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
- Collections.sort(cartridges);
+ List<String> cartridgeTypes = serviceGroupDefinition.getCartridges();
- if (log.isDebugEnabled()) {
- log.debug("Returning subscribed cartridges " + cartridges.size());
- }
-
- /*if(cartridges.isEmpty()) {
- String msg = "Cannot find any subscribed Cartridge, matching the given string: "+cartridgeSearchString;
- log.error(msg);
- throw new RestAPIException(msg);
- }*/
+ Set<String> duplicates = findDuplicates(cartridgeTypes);
+ if (duplicates.size() > 0) {
+ StringBuffer buf = new StringBuffer();
+ for (String dup : duplicates) {
+ buf.append(dup).append(" ");
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("duplicate cartridges defined: " + buf.toString());
+ }
+ throw new RestAPIException("Invalid Service Group definition, duplicate cartridges defined:" + buf.toString());
+ }
- return cartridges;
- }
+ CloudControllerServiceClient ccServiceClient = null;
- private static Cartridge getCartridgeFromSubscription(CartridgeSubscription subscription) throws RestAPIException {
+ try {
+ ccServiceClient = CloudControllerServiceClient.getServiceClient();
+ } catch (AxisFault axisFault) {
+ throw new RestAPIException(axisFault);
+ }
- if (subscription == null) {
- return null;
- }
- try {
- Cartridge cartridge = new Cartridge();
- cartridge.setCartridgeType(subscription.getCartridgeInfo()
- .getType());
- cartridge.setMultiTenant(subscription.getCartridgeInfo()
- .getMultiTenant());
- cartridge
- .setProvider(subscription.getCartridgeInfo().getProvider());
- cartridge.setVersion(subscription.getCartridgeInfo().getVersion());
- cartridge.setDescription(subscription.getCartridgeInfo()
- .getDescription());
- cartridge.setDisplayName(subscription.getCartridgeInfo()
- .getDisplayName());
- cartridge.setCartridgeAlias(subscription.getAlias());
- cartridge.setHostName(subscription.getHostName());
- cartridge.setMappedDomain(subscription.getMappedDomain());
- if (subscription.getRepository() != null) {
- cartridge.setRepoURL(subscription.getRepository().getUrl());
+ for (String cartridgeType : cartridgeTypes) {
+ try {
+ if (ccServiceClient.getCartridgeInfo(cartridgeType) == null) {
+ // cartridge is not deployed, can't continue
+ log.error("invalid cartridge found in service group " + cartridgeType);
+ throw new RestAPIException("No Cartridge Definition found with type " + cartridgeType);
+ }
+ } catch (RemoteException e) {
+ throw new RestAPIException(e);
+ } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
+ throw new RestAPIException(e);
+ }
+ }
}
- if (subscription instanceof DataCartridgeSubscription) {
- DataCartridgeSubscription dataCartridgeSubscription = (DataCartridgeSubscription) subscription;
- cartridge.setDbHost(dataCartridgeSubscription.getDBHost());
- cartridge.setDbUserName(dataCartridgeSubscription
- .getDBUsername());
- cartridge
- .setPassword(dataCartridgeSubscription.getDBPassword());
- }
+ // if any sub groups are specified in the group, they should be already deployed
+ if (serviceGroupDefinition.getGroups() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("checking subGroups in service group " + serviceGroupDefinition.getName());
+ }
- if (subscription.getLbClusterId() != null
- && !subscription.getLbClusterId().isEmpty()) {
- cartridge.setLbClusterId(subscription.getLbClusterId());
- }
+ List<ServiceGroupDefinition> groupDefinitions = serviceGroupDefinition.getGroups();
+ List<String> groupNames = new ArrayList<String>();
+ for (ServiceGroupDefinition groupList : groupDefinitions) {
+ groupNames.add(groupList.getName());
+ }
- cartridge.setClusterId(subscription.getClusterDomain());
- cartridge.setStatus(subscription.getSubscriptionStatus());
- cartridge.setPortMappings(subscription.getCartridgeInfo()
- .getPortMappings());
+ Set<String> duplicates = findDuplicates(groupNames);
+ if (duplicates.size() > 0) {
- if (subscription.getCartridgeInfo().getProperties() != null) {
- for (org.apache.stratos.cloud.controller.stub.Property property : subscription.getCartridgeInfo().getProperties()) {
- if (property.getName().equals("load.balancer")) {
- cartridge.setLoadBalancer(true);
+ StringBuffer buf = new StringBuffer();
+ for (String dup : duplicates) {
+ buf.append(dup).append(" ");
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("duplicate subGroups defined: " + buf.toString());
}
+ throw new RestAPIException("Invalid Service Group definition, duplicate subGroups defined:" + buf.toString());
}
}
- if (subscription.getCartridgeInfo().getServiceGroup() != null) {
- cartridge.setServiceGroup(subscription.getCartridgeInfo().getServiceGroup());
- }
- return cartridge;
+ ServiceGroup serviceGroup = ObjectConverter.convertServiceGroupDefinitionToASStubServiceGroup(serviceGroupDefinition);
+
+ AutoscalerServiceClient asServiceClient = AutoscalerServiceClient.getServiceClient();
+ asServiceClient.addServiceGroup(serviceGroup);
} catch (Exception e) {
- String msg = "Unable to extract the Cartridge from subscription. Cause: " + e.getMessage();
- log.error(msg);
- throw new RestAPIException(msg);
+ String message = "Could not add service group";
+ log.error(message, e);
+ throw new RestAPIException(message, e);
}
-
}
- public static CartridgeSubscription getCartridgeSubscription(String alias, ConfigurationContext configurationContext) {
- return CartridgeSubscriptionManager.getCartridgeSubscription(ApplicationManagementUtil.getTenantId(configurationContext), alias);
- }
-
- // Util methods for clusters
+ /**
+ * returns any duplicates in a List
+ *
+ * @param checkedList
+ * @return
+ */
+ private static Set<String> findDuplicates(List<String> checkedList) {
+ final Set<String> retVals = new HashSet<String>();
+ final Set<String> set1 = new HashSet<String>();
- public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenant(ConfigurationContext configurationContext) {
+ for (String val : checkedList) {
- Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
- getTenantId(configurationContext), null);
- ArrayList<org.apache.stratos.common.beans.topology.Cluster> clusters =
- new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
- for (Cluster cluster : clusterSet) {
- clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
+ if (!set1.add(val)) {
+ retVals.add(val);
+ }
}
- org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
- new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
- arrCluster = clusters.toArray(arrCluster);
- return arrCluster;
-
+ return retVals;
}
- public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenantAndCartridgeType(ConfigurationContext configurationContext,
- String cartridgeType) {
+ public static ServiceGroupDefinition getServiceGroupDefinition(String name) throws RestAPIException {
- Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
- getTenantId(configurationContext), cartridgeType);
- List<org.apache.stratos.common.beans.topology.Cluster> clusters =
- new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
- for (Cluster cluster : clusterSet) {
- clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
+ if (log.isDebugEnabled()) {
+ log.debug("Reading service group: [group-name] " + name);
}
- org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
- new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
- arrCluster = clusters.toArray(arrCluster);
- return arrCluster;
- }
-
- // Util methods for repo actions
-
- public static void getGitRepositoryNotification(Payload payload) throws RestAPIException {
try {
+ AutoscalerServiceClient asServiceClient = AutoscalerServiceClient.getServiceClient();
+ ServiceGroup serviceGroup = asServiceClient.getServiceGroup(name);
+ if (serviceGroup == null) {
+ return null;
+ }
- RepositoryNotification repoNotification = new RepositoryNotification();
- repoNotification.updateRepository(payload.getRepository().getUrl());
+ ServiceGroupDefinition serviceGroupDef = ObjectConverter.convertStubServiceGroupToServiceGroupDefinition(serviceGroup);
+ return serviceGroupDef;
} catch (Exception e) {
- String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
- }
-
- public static void synchronizeRepository(CartridgeSubscription cartridgeSubscription) throws RestAPIException {
- try {
- RepositoryNotification repoNotification = new RepositoryNotification();
- repoNotification.updateRepository(cartridgeSubscription);
- } catch (Exception e) {
- String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
+ String message = "Could not get service group: [group-name] " + name;
+ log.error(message, e);
+ throw new RestAPIException(message, e);
}
}
- // Util methods for service groups
-
- public static void addServiceGroup(ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException {
-
- try {
- serviceGropingManager.deployServiceGroupDefinition(serviceGroupDefinition);
+ public static ServiceGroupDefinition[] getServiceGroupDefinitions() throws RestAPIException {
- } catch (InvalidServiceGroupException e) {
- throw new RestAPIException(e);
- } catch (ServiceGroupDefinitioException e) {
- throw new RestAPIException(e);
- } catch (ADCException e) {
- throw new RestAPIException(e);
- } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
- throw new RestAPIException(e);
+ if (log.isDebugEnabled()) {
+ log.debug("Reading service groups...");
}
- log.info("Successfully created the Service Group Definition with name " + serviceGroupDefinition.getName());
- }
-
- public static ServiceGroupDefinition getServiceGroupDefinition(String serviceGroupDefinitionName) throws RestAPIException {
-
try {
- return serviceGropingManager.getServiceGroupDefinition(serviceGroupDefinitionName);
+ AutoscalerServiceClient asServiceClient = AutoscalerServiceClient.getServiceClient();
+ ServiceGroup[] serviceGroups = asServiceClient.getServiceGroups();
+ if (serviceGroups == null || serviceGroups.length == 0) {
+ return null;
+ }
- } catch (ServiceGroupDefinitioException e) {
- throw new RestAPIException(e);
- } catch (ADCException e) {
- throw new RestAPIException(e);
- }
- }
+ ServiceGroupDefinition[] serviceGroupDefinitions = new ServiceGroupDefinition[serviceGroups.length];
+ for (int i = 0; i < serviceGroups.length; i++) {
+ serviceGroupDefinitions[i] = ObjectConverter.convertStubServiceGroupToServiceGroupDefinition(serviceGroups[i]);
+ }
+ return serviceGroupDefinitions;
- public static ServiceGroupDefinition[] getServiceGroupDefinitions() throws RestAPIException {
- try {
- return serviceGropingManager.getServiceGroupDefinitions();
- } catch (ADCException e) {
- throw new RestAPIException(e);
- } catch (ServiceGroupDefinitioException e) {
+ } catch (Exception e) {
throw new RestAPIException(e);
}
}
- public static void removeServiceGroup(String serviceGroupDefinitionName) throws RestAPIException {
+ public static void removeServiceGroup(String name) throws RestAPIException {
try {
- serviceGropingManager.undeployServiceGroupDefinition(serviceGroupDefinitionName);
+ if (log.isDebugEnabled()) {
+ log.debug("Removing service group: [name] " + name);
+ }
- } catch (ServiceGroupDefinitioException e) {
- throw new RestAPIException(e);
- } catch (ADCException e) {
+ AutoscalerServiceClient autoscalerServiceClient = AutoscalerServiceClient.getServiceClient();
+ autoscalerServiceClient.undeployServiceGroupDefinition(name);
+
+ } catch (Exception e) {
throw new RestAPIException(e);
}
- log.info("Successfully deleted the Service Group Definition with name " + serviceGroupDefinitionName);
+ log.info("Successfully removed the service group: [group-name] " + name);
}
// Util methods for Applications
@@ -957,7 +831,7 @@ public class StratosApiV41Utils {
if (appDefinition.getProperty() != null) {
org.apache.stratos.autoscaler.stub.Properties properties = new org.apache.stratos.autoscaler.stub.Properties();
- for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) {
+ for (org.apache.stratos.manager.domain.PropertyBean propertyBean : appDefinition.getProperty()) {
org.apache.stratos.autoscaler.stub.Property property = new org.apache.stratos.autoscaler.stub.Property();
property.setName(propertyBean.getName());
property.setValue(propertyBean.getValue());
@@ -1033,13 +907,8 @@ public class StratosApiV41Utils {
}
}
- public static ApplicationSubscription getApplicationSubscriptions(String appId, ConfigurationContext ctxt) throws RestAPIException {
- CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager();
- try {
- return subscriptionMgr.getApplicationSubscription(appId, ApplicationManagementUtil.getTenantId(ctxt));
- } catch (ApplicationSubscriptionException e) {
- throw new RestAPIException(e);
- }
+ public static List<ApplicationSubscription> getApplicationSubscriptions(String applicationId) throws RestAPIException {
+ return null;
}
public static void removeApplication(String applicationId) throws RestAPIException {
@@ -1184,17 +1053,17 @@ public class StratosApiV41Utils {
}
- private static void addClustersToApplicationBean(ApplicationBean applicationBean, Application application) {
- Map<String, ClusterDataHolder> topLevelClusterDataMap = application.getClusterDataMap();
- for (Map.Entry<String, ClusterDataHolder> entry : topLevelClusterDataMap.entrySet()) {
- ClusterDataHolder clusterDataHolder = entry.getValue();
- String clusterId = clusterDataHolder.getClusterId();
- String serviceType = clusterDataHolder.getServiceType();
- TopologyManager.acquireReadLockForCluster(serviceType, clusterId);
- Cluster topLevelCluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterId);
- applicationBean.getClusters().add(ObjectConverter.convertClusterToClusterBean(topLevelCluster, entry.getKey()));
- }
- }
+// private static void addClustersToApplicationBean(ApplicationBean applicationBean, Application application) {
+// Map<String, ClusterDataHolder> topLevelClusterDataMap = application.getClusterDataMap();
+// for (Map.Entry<String, ClusterDataHolder> entry : topLevelClusterDataMap.entrySet()) {
+// ClusterDataHolder clusterDataHolder = entry.getValue();
+// String clusterId = clusterDataHolder.getClusterId();
+// String serviceType = clusterDataHolder.getServiceType();
+// TopologyManager.acquireReadLockForCluster(serviceType, clusterId);
+// Cluster topLevelCluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterId);
+// applicationBean.getClusters().add(ObjectConverter.convertClusterToClusterBean(topLevelCluster, entry.getKey()));
+// }
+// }
private static void addClustersInstancesToApplicationInstanceBean(
ApplicationInstanceBean applicationInstanceBean,
@@ -1489,27 +1358,27 @@ public class StratosApiV41Utils {
return false;
}
- public static void updateSubscriptionProperties(ConfigurationContext context, String alias, List<PropertyBean> property) throws RestAPIException {
- AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
- if (autoscalerServiceClient != null) {
- try {
- Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(context)
- , alias);
- if (cluster == null) {
- throw new RestAPIException("No matching cluster found for [alias] " + alias);
- }
- if (property != null) {
- autoscalerServiceClient.updateClusterMonitor(cluster.getClusterId(), ObjectConverter.convertPropertyBeansToProperties(property));
- }
- } catch (AutoScalerServiceInvalidArgumentExceptionException e) {
- String message = e.getFaultMessage().getInvalidArgumentException().getMessage();
- log.error(message, e);
- throw new RestAPIException(message, e);
- } catch (RemoteException e) {
- String msg = "Error while connecting to Autoscaler Service. " + e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(e.getMessage(), e);
- }
- }
- }
+// public static void updateSubscriptionProperties(ConfigurationContext context, String alias, List<PropertyBean> property) throws RestAPIException {
+// AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
+// if (autoscalerServiceClient != null) {
+// try {
+// Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(context)
+// , alias);
+// if (cluster == null) {
+// throw new RestAPIException("No matching cluster found for [alias] " + alias);
+// }
+// if (property != null) {
+// autoscalerServiceClient.updateClusterMonitor(cluster.getClusterId(), ObjectConverter.convertPropertyBeansToProperties(property));
+// }
+// } catch (AutoScalerServiceInvalidArgumentExceptionException e) {
+// String message = e.getFaultMessage().getInvalidArgumentException().getMessage();
+// log.error(message, e);
+// throw new RestAPIException(message, e);
+// } catch (RemoteException e) {
+// String msg = "Error while connecting to Autoscaler Service. " + e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(e.getMessage(), e);
+// }
+// }
+// }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/MockContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/MockContext.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/MockContext.java
index dfa6aa2..2931eb3 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/MockContext.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/MockContext.java
@@ -19,9 +19,8 @@
package org.apache.stratos.rest.endpoint.mock;
import org.apache.stratos.common.beans.TenantInfoBean;
-import org.apache.stratos.manager.dto.Cartridge;
-import org.apache.stratos.manager.dto.SubscriptionInfo;
-import org.apache.stratos.manager.subscription.SubscriptionDomain;
+import org.apache.stratos.manager.domain.Cartridge;
+import org.apache.stratos.manager.domain.SubscriptionInfo;
import org.apache.stratos.common.beans.UserInfoBean;
import org.apache.stratos.common.beans.CartridgeInfoBean;
import org.apache.stratos.common.beans.StratosApiResponse;
@@ -34,6 +33,7 @@ import org.apache.stratos.common.beans.cartridge.definition.CartridgeDefinitionB
import org.apache.stratos.common.beans.cartridge.definition.ServiceDefinitionBean;
import org.apache.stratos.common.beans.subscription.domain.SubscriptionDomainBean;
import org.apache.stratos.common.beans.topology.Cluster;
+import org.apache.stratos.messaging.domain.tenant.SubscriptionDomain;
import org.apache.stratos.rest.endpoint.util.converter.ObjectConverter;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
import org.wso2.carbon.context.CarbonContext;
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosApiV40Mock.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosApiV40Mock.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosApiV40Mock.java
index f2578de..5250b7b 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosApiV40Mock.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/mock/StratosApiV40Mock.java
@@ -24,8 +24,8 @@ import java.net.URI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.common.beans.TenantInfoBean;
-import org.apache.stratos.manager.dto.Cartridge;
-import org.apache.stratos.manager.dto.SubscriptionInfo;
+import org.apache.stratos.manager.domain.Cartridge;
+import org.apache.stratos.manager.domain.SubscriptionInfo;
import org.apache.stratos.manager.exception.ADCException;
import org.apache.stratos.common.beans.UserInfoBean;
import org.apache.stratos.rest.endpoint.Utils;
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index b2dccb4..44b18eb 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -24,7 +24,10 @@ import org.apache.stratos.autoscaler.stub.deployment.partition.ChildLevelNetwork
import org.apache.stratos.autoscaler.stub.deployment.partition.ChildLevelPartition;
import org.apache.stratos.autoscaler.stub.deployment.policy.ChildPolicy;
import org.apache.stratos.autoscaler.stub.pojo.*;
+import org.apache.stratos.autoscaler.stub.pojo.Dependencies;
+import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
import org.apache.stratos.cloud.controller.stub.domain.*;
+import org.apache.stratos.cloud.controller.stub.domain.PortMapping;
import org.apache.stratos.common.Properties;
import org.apache.stratos.common.Property;
import org.apache.stratos.common.beans.GroupBean;
@@ -42,15 +45,15 @@ import org.apache.stratos.common.beans.kubernetes.PortRange;
import org.apache.stratos.common.beans.subscription.domain.SubscriptionDomainBean;
import org.apache.stratos.common.beans.topology.*;
import org.apache.stratos.common.util.CommonUtil;
-import org.apache.stratos.manager.composite.application.beans.*;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
-import org.apache.stratos.manager.subscription.SubscriptionDomain;
+import org.apache.stratos.manager.domain.*;
+import org.apache.stratos.manager.domain.DependencyDefinitions;
+import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
import org.apache.stratos.messaging.domain.applications.Application;
import org.apache.stratos.messaging.domain.applications.Group;
import org.apache.stratos.messaging.domain.instance.ApplicationInstance;
import org.apache.stratos.messaging.domain.instance.ClusterInstance;
import org.apache.stratos.messaging.domain.instance.GroupInstance;
+import org.apache.stratos.messaging.domain.tenant.SubscriptionDomain;
import org.apache.stratos.messaging.domain.topology.Cluster;
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
@@ -899,28 +902,28 @@ public class ObjectConverter {
return networkPartitionGroupsBeans;
}
- public static ServiceDefinitionBean convertToServiceDefinitionBean(Service service) {
-
- ServiceDefinitionBean serviceDefinitionBean = new ServiceDefinitionBean();
- serviceDefinitionBean.setCartridgeType(service.getType());
- serviceDefinitionBean.setTenantRange(service.getTenantRange());
- serviceDefinitionBean.setClusterDomain(service.getClusterId());
- serviceDefinitionBean.setIsPublic(service.getIsPublic());
- serviceDefinitionBean.setAutoscalingPolicyName(service.getAutoscalingPolicyName());
- serviceDefinitionBean.setDeploymentPolicyName(service.getDeploymentPolicyName());
-
- return serviceDefinitionBean;
- }
-
- public static List<ServiceDefinitionBean> convertToServiceDefinitionBeans(Collection<Service> services) {
-
- List<ServiceDefinitionBean> serviceDefinitionBeans = new ArrayList<ServiceDefinitionBean>();
-
- for (Service service : services) {
- serviceDefinitionBeans.add(convertToServiceDefinitionBean(service));
- }
- return serviceDefinitionBeans;
- }
+// public static ServiceDefinitionBean convertToServiceDefinitionBean(Service service) {
+//
+// ServiceDefinitionBean serviceDefinitionBean = new ServiceDefinitionBean();
+// serviceDefinitionBean.setCartridgeType(service.getType());
+// serviceDefinitionBean.setTenantRange(service.getTenantRange());
+// serviceDefinitionBean.setClusterDomain(service.getClusterId());
+// serviceDefinitionBean.setIsPublic(service.getIsPublic());
+// serviceDefinitionBean.setAutoscalingPolicyName(service.getAutoscalingPolicyName());
+// serviceDefinitionBean.setDeploymentPolicyName(service.getDeploymentPolicyName());
+//
+// return serviceDefinitionBean;
+// }
+
+// public static List<ServiceDefinitionBean> convertToServiceDefinitionBeans(Collection<Service> services) {
+//
+// List<ServiceDefinitionBean> serviceDefinitionBeans = new ArrayList<ServiceDefinitionBean>();
+//
+// for (Service service : services) {
+// serviceDefinitionBeans.add(convertToServiceDefinitionBean(service));
+// }
+// return serviceDefinitionBeans;
+// }
public static org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesCluster
convertToCCKubernetesClusterPojo(KubernetesCluster kubernetesClusterBean) {
@@ -1256,16 +1259,16 @@ public class ObjectConverter {
return subscribableInfo;
}
- private static List<org.apache.stratos.manager.composite.application.beans.PropertyBean>
+ private static List<org.apache.stratos.manager.domain.PropertyBean>
convertStubPropertiesToPropertyBeanList(org.apache.stratos.autoscaler.stub.Properties properties) {
- List<org.apache.stratos.manager.composite.application.beans.PropertyBean> propertyBeanList =
- new ArrayList<org.apache.stratos.manager.composite.application.beans.PropertyBean>();
+ List<org.apache.stratos.manager.domain.PropertyBean> propertyBeanList =
+ new ArrayList<org.apache.stratos.manager.domain.PropertyBean>();
if((properties != null) && (properties.getProperties() != null)) {
for (org.apache.stratos.autoscaler.stub.Property property : properties.getProperties()) {
if((property != null) && (property.getValue() instanceof String)) {
- org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean =
- new org.apache.stratos.manager.composite.application.beans.PropertyBean();
+ org.apache.stratos.manager.domain.PropertyBean propertyBean =
+ new org.apache.stratos.manager.domain.PropertyBean();
propertyBean.setName(property.getName());
propertyBean.setValue(String.valueOf(property.getValue()));
propertyBeanList.add(propertyBean);
@@ -1310,10 +1313,10 @@ public class ObjectConverter {
}
private static org.apache.stratos.autoscaler.stub.Properties convertPropertyBeansToStubProperties(
- List<org.apache.stratos.manager.composite.application.beans.PropertyBean> property) {
+ List<org.apache.stratos.manager.domain.PropertyBean> property) {
org.apache.stratos.autoscaler.stub.Properties prop = new org.apache.stratos.autoscaler.stub.Properties();
if (property != null) {
- for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : property) {
+ for (org.apache.stratos.manager.domain.PropertyBean propertyBean : property) {
org.apache.stratos.autoscaler.stub.Property p = new org.apache.stratos.autoscaler.stub.Property();
p.setName(propertyBean.getName());
p.setValue(propertyBean.getValue());
@@ -1528,4 +1531,125 @@ public class ObjectConverter {
}
return carbonTenantInfoBean;
}
+
+ public static ServiceGroup convertServiceGroupDefinitionToASStubServiceGroup(ServiceGroupDefinition serviceGroupDefinition) throws ServiceGroupDefinitioException {
+ ServiceGroup servicegroup = new ServiceGroup();
+
+ // implement conversion (mostly List -> Array)
+ servicegroup.setGroupscalingEnabled(serviceGroupDefinition.isGroupScalingEnabled);
+ List<ServiceGroupDefinition> groupsDef = serviceGroupDefinition.getGroups();
+ List<String> cartridgesDef = serviceGroupDefinition.getCartridges();
+
+ servicegroup.setName(serviceGroupDefinition.getName());
+
+ if (groupsDef == null) {
+ groupsDef = new ArrayList<ServiceGroupDefinition>(0);
+ }
+
+ if (cartridgesDef == null) {
+ cartridgesDef = new ArrayList<String>(0);
+ }
+
+ ServiceGroup[] subGroups = new ServiceGroup[groupsDef.size()];
+ String[] cartridges = new String[cartridgesDef.size()];
+
+ int i = 0;
+ for (ServiceGroupDefinition groupDefinition : groupsDef) {
+ subGroups[i] = convertServiceGroupDefinitionToASStubServiceGroup(groupDefinition);
+ ++i;
+ }
+
+ servicegroup.setGroups(subGroups);
+ cartridges = cartridgesDef.toArray(cartridges);
+ servicegroup.setCartridges(cartridges);
+
+ DependencyDefinitions depDefs = serviceGroupDefinition.getDependencies();
+
+ if (depDefs != null) {
+ Dependencies dependencies = new Dependencies();
+ List<String> startupOrdersDef = depDefs.getStartupOrders();
+ if (startupOrdersDef != null) {
+ String[] startupOrders = new String[startupOrdersDef.size()];
+ startupOrders = startupOrdersDef.toArray(startupOrders);
+ dependencies.setStartupOrders(startupOrders);
+ }
+ // validate termination behavior
+ validateTerminationBehavior(depDefs.getTerminationBehaviour());
+ dependencies.setTerminationBehaviour(depDefs.getTerminationBehaviour());
+ if (depDefs.getScalingDependants() != null) {
+ dependencies.setScalingDependants(depDefs.getScalingDependants()
+ .toArray(new String[depDefs.getScalingDependants().size()]));
+ }
+ servicegroup.setDependencies(dependencies);
+ }
+
+ return servicegroup;
+ }
+
+ public static ServiceGroupDefinition convertStubServiceGroupToServiceGroupDefinition(ServiceGroup serviceGroup) {
+ if(serviceGroup == null) {
+ return null;
+ }
+
+ ServiceGroupDefinition servicegroupDef = new ServiceGroupDefinition();
+ servicegroupDef.setName(serviceGroup.getName());
+ String[] cartridges = serviceGroup.getCartridges();
+ ServiceGroup[] groups = serviceGroup.getGroups();
+ org.apache.stratos.autoscaler.stub.pojo.Dependencies deps = serviceGroup.getDependencies();
+
+ List<ServiceGroupDefinition> groupDefinitions = new ArrayList<ServiceGroupDefinition>(groups.length);
+ for (ServiceGroup group : groups) {
+ if (group != null) {
+ groupDefinitions.add(convertStubServiceGroupToServiceGroupDefinition(group));
+ }
+ }
+
+ if (deps != null) {
+ DependencyDefinitions depsDef = new DependencyDefinitions();
+ String[] startupOrders = deps.getStartupOrders();
+ if (startupOrders != null && startupOrders[0] != null) {
+ List<String> startupOrdersDef = Arrays.asList(startupOrders);
+ depsDef.setStartupOrders(startupOrdersDef);
+ }
+
+ String [] scalingDependants = deps.getScalingDependants();
+ if (scalingDependants != null && scalingDependants[0] != null) {
+ List<String> scalingDependenciesDef = Arrays.asList(scalingDependants);
+ depsDef.setScalingDependants(scalingDependenciesDef);
+ }
+
+ depsDef.setTerminationBehaviour(deps.getTerminationBehaviour());
+ servicegroupDef.setDependencies(depsDef);
+ }
+
+ List<String> cartridgesDef = new ArrayList<String>(Arrays.asList(cartridges));
+ //List<ServiceGroupDefinition> subGroupsDef = new ArrayList<ServiceGroupDefinition>(groups.length);
+ if (cartridges[0] != null) {
+ servicegroupDef.setCartridges(cartridgesDef);
+ }
+ if (groups != null) {
+ servicegroupDef.setGroups(groupDefinitions);
+ }
+
+ return servicegroupDef;
+ }
+
+ /**
+ * Validates terminationBehavior. The terminationBehavior should be one of the following:
+ * 1. terminate-none
+ * 2. terminate-dependents
+ * 3. terminate-all
+ *
+ * @throws ServiceGroupDefinitioException if terminationBehavior is different to what is
+ * listed above
+ */
+ private static void validateTerminationBehavior(String terminationBehavior) throws ServiceGroupDefinitioException {
+
+ if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) ||
+ "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) {
+ throw new ServiceGroupDefinitioException("Invalid Termination Behaviour specified: [ " +
+ terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " +
+ " 'terminate-all' ");
+ }
+ }
}
[04/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java
deleted file mode 100644
index 491cc07..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/model/TopologyClusterInformationModel.java
+++ /dev/null
@@ -1,296 +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.manager.topology.model;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-
-public class TopologyClusterInformationModel {
-
- private static final Log log = LogFactory.getLog(TopologyClusterInformationModel.class);
-
- //private Map<Integer, Set<CartridgeTypeContext>> tenantIdToCartridgeTypeContextMap;
- private static TopologyClusterInformationModel topologyClusterInformationModel;
- private Map<String, Cluster> clusterIdToClusterMap;
- private Map<String, Cluster> serviceNameToClusterMap;
- private DataInsertionAndRetrievalManager dataInsertionNRetrievalMgr;
- private boolean initialized;
-
- //locks
- private static volatile ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- private static volatile ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();
-
- private TopologyClusterInformationModel() {
- //tenantIdToCartridgeTypeContextMap = new HashMap<Integer, Set<CartridgeTypeContext>>();
- clusterIdToClusterMap = new HashMap<String, Cluster>();
- serviceNameToClusterMap = new HashMap<String, Cluster>();
- dataInsertionNRetrievalMgr = new DataInsertionAndRetrievalManager();
- }
-
- public static TopologyClusterInformationModel getInstance () {
-
- if(topologyClusterInformationModel == null) {
- synchronized (TopologyClusterInformationModel.class) {
- if (topologyClusterInformationModel == null) {
- topologyClusterInformationModel = new TopologyClusterInformationModel();
- }
- }
- }
-
- return topologyClusterInformationModel;
- }
-
- public void addCluster (Cluster cluster) {
-
- if(log.isDebugEnabled()) {
- log.debug(" Adding cluster ["+cluster+"] ");
- }
- clusterIdToClusterMap.put(cluster.getClusterId(), cluster);
- serviceNameToClusterMap.put(cluster.getServiceName(), cluster);
- }
-
- public Cluster getCluster (int tenantId, String subscriptionAlias) {
-
- String clusterId = dataInsertionNRetrievalMgr.getCartridgeSubscription(tenantId, subscriptionAlias).getClusterDomain();
- Cluster cluster = clusterIdToClusterMap.get(clusterId);
- if(log.isDebugEnabled()) {
- log.debug(" Found cluster ["+cluster+"] with id ["+clusterId+"] ");
- }
- return cluster;
- }
-
- public Cluster getCluster (String cartridgeType) {
-
- Service service;
- Cluster cluster = null;
- try {
- service = dataInsertionNRetrievalMgr.getService(cartridgeType);
- } catch (PersistenceManagerException e) {
- log.error("Exception occurred when retrieving service [" + cartridgeType +"] ");
- return null;
- }
-
- if(service != null) {
- String clusterId = service.getClusterId();
- cluster = clusterIdToClusterMap.get(clusterId);
- if(log.isDebugEnabled()) {
- log.debug(" Found cluster ["+cluster+"] with id ["+clusterId+"] ");
- }
- }
- return cluster;
- }
-
- public Set<Cluster> getClusters (int tenantId, String cartridgeType) {
- if(log.isDebugEnabled()) {
- log.info(" Getting cluster for tenant id [" + tenantId + "] ");
- }
- Collection<CartridgeSubscription> subscriptions = null;
-
- if(cartridgeType != null) {
- subscriptions = dataInsertionNRetrievalMgr.getCartridgeSubscriptions(tenantId, cartridgeType);
- }else {
- subscriptions = dataInsertionNRetrievalMgr.getCartridgeSubscriptions(tenantId);
- }
-
- Set<Cluster> clusterSet = new HashSet<Cluster>();
- if (subscriptions != null) {
- for (CartridgeSubscription cartridgeSubscription : subscriptions) {
-
- // TODO -- check this. Sometimes getting clusterId some non-meaningful value
- String clusterId = cartridgeSubscription.getClusterDomain();
- if(log.isDebugEnabled()) {
- log.info("Finding cluster with id ["+clusterId+"] ");
- }
- Cluster foundCluster = clusterIdToClusterMap.get(clusterId);
- if (foundCluster != null) {
- clusterSet.add(foundCluster);
- }
- }
- }
- return clusterSet;
- }
-
- public Set<Cluster> getClusters(String cartridgeType) {
-
- Set<Cluster> clusterSet = new HashSet<Cluster>();
-
- if (log.isDebugEnabled()) {
- log.info("Finding cluster with service name [" + cartridgeType
- + "] ");
- }
- Cluster foundCluster = serviceNameToClusterMap.get(cartridgeType);
- if (foundCluster != null) {
- clusterSet.add(foundCluster);
- }
-
- return clusterSet;
- }
-
-// public void removeCluster (int tenantId, String cartridgeType, String subscriptionAlias) {
-//
-// Set<CartridgeTypeContext> cartridgeTypeContextSet = null;
-// Set<SubscriptionAliasContext> subscriptionAliasContextSet = null;
-//
-// writeLock.lock();
-// try {
-// //check if a set of CartridgeTypeContext instances already exist for given tenant Id
-// cartridgeTypeContextSet = tenantIdToCartridgeTypeContextMap.get(tenantId);
-// if(cartridgeTypeContextSet != null) {
-// CartridgeTypeContext cartridgeTypeContext = null;
-// //iterate through the set
-// Iterator<CartridgeTypeContext> typeCtxIterator = cartridgeTypeContextSet.iterator();
-// while (typeCtxIterator.hasNext()) {
-// //see if the set contains a CartridgeTypeContext instance with the given cartridge type
-// cartridgeTypeContext = typeCtxIterator.next();
-// if (cartridgeTypeContext.getType().equals(cartridgeType)){
-// //if so, get the SubscriptionAliasContext set
-// subscriptionAliasContextSet = cartridgeTypeContext.getSubscriptionAliasContextSet();
-// break;
-// }
-// }
-// if(subscriptionAliasContextSet != null) {
-// //iterate through the set
-// Iterator<SubscriptionAliasContext> aliasIterator = subscriptionAliasContextSet.iterator();
-// while (aliasIterator.hasNext()) {
-// //see if the set contains a SubscriptionAliasContext instance with the given alias
-// SubscriptionAliasContext subscriptionAliasContext = aliasIterator.next();
-// if (subscriptionAliasContext.getSubscriptionAlias().equals(subscriptionAlias)) {
-// //remove the existing one
-// aliasIterator.remove();
-//
-// if (log.isDebugEnabled()) {
-// log.debug("Removed cluster for tenant " + tenantId + ", type " + cartridgeType +
-// ", subscription alias " + subscriptionAlias);
-// }
-//
-// break;
-// }
-// }
-// }
-// }
-//
-// } finally {
-// writeLock.unlock();
-// }
-// }
-
- public void removeCluster (String clusterId) {
-
- if(log.isDebugEnabled()) {
- log.debug(" Removing cluster ["+clusterId+"] ");
- }
- clusterIdToClusterMap.remove(clusterId);
- }
-
- public boolean isInitialized() {
- return initialized;
- }
-
- public void setInitialized(boolean initialized) {
- this.initialized = initialized;
- }
-
-// private class CartridgeTypeContext {
-//
-// private String type;
-// private Set<SubscriptionAliasContext> subscriptionAliasContextSet;
-//
-// public CartridgeTypeContext (String type) {
-// this.type = type;
-// }
-//
-// public void setSubscriptionAliasContextSet (Set<SubscriptionAliasContext> subscriptionAliasContextSet) {
-// this.subscriptionAliasContextSet = subscriptionAliasContextSet;
-// }
-//
-// public String getType () {
-// return type;
-// }
-//
-// public Set<SubscriptionAliasContext> getSubscriptionAliasContextSet () {
-// return subscriptionAliasContextSet;
-// }
-//
-// public boolean equals(Object other) {
-//
-// if(this == other) {
-// return true;
-// }
-// if(!(other instanceof CartridgeTypeContext)) {
-// return false;
-// }
-//
-// CartridgeTypeContext that = (CartridgeTypeContext)other;
-// return this.type.equals(that.type);
-// }
-//
-// public int hashCode () {
-// return type.hashCode();
-// }
-// }
-//
-// private class SubscriptionAliasContext {
-//
-// private String subscriptionAlias;
-// private Cluster cluster;
-//
-// public SubscriptionAliasContext(String subscriptionAlias, Cluster cluster) {
-// this.subscriptionAlias = subscriptionAlias;
-// this.cluster = cluster;
-// }
-//
-// public String getSubscriptionAlias () {
-// return subscriptionAlias;
-// }
-//
-// public Cluster getCluster () {
-// return cluster;
-// }
-//
-// public boolean equals(Object other) {
-//
-// if(this == other) {
-// return true;
-// }
-// if(!(other instanceof SubscriptionAliasContext)) {
-// return false;
-// }
-//
-// SubscriptionAliasContext that = (SubscriptionAliasContext)other;
-// return this.subscriptionAlias.equals(that.subscriptionAlias);
-// }
-//
-// public int hashCode () {
-// return subscriptionAlias.hashCode();
-// }
-// }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
deleted file mode 100644
index 3912821..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/topology/receiver/StratosManagerTopologyEventReceiver.java
+++ /dev/null
@@ -1,477 +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.manager.topology.receiver;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Service;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.topology.*;
-import org.apache.stratos.messaging.listener.topology.*;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
-
-import java.util.concurrent.ExecutorService;
-
-public class StratosManagerTopologyEventReceiver implements Runnable {
-
- private static final Log log = LogFactory.getLog(StratosManagerTopologyEventReceiver.class);
-
- private TopologyEventReceiver topologyEventReceiver;
- private boolean terminated;
- private ExecutorService executorService;
-
- public StratosManagerTopologyEventReceiver() {
- this.terminated = false;
- this.topologyEventReceiver = new TopologyEventReceiver();
- addEventListeners();
- }
-
- private void addEventListeners() {
- //add listner to Complete Topology Event
- topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- if (TopologyClusterInformationModel.getInstance().isInitialized()) {
- return;
- }
-
- log.info("[CompleteTopologyEventListener] Received: " + event.getClass());
-
- try {
- TopologyManager.acquireReadLock();
-
- for (Service service : TopologyManager.getTopology()
- .getServices()) {
- // iterate through all clusters
- for (Cluster cluster : service.getClusters()) {
- TopologyClusterInformationModel.getInstance()
- .addCluster(cluster);
- }
- }
-
- TopologyClusterInformationModel.getInstance().setInitialized(true);
-
- } finally {
- TopologyManager.releaseReadLock();
- }
- }
- });
-
- //Cluster Created event listner
- topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- log.info("[ClusterCreatedEventListener] Received: " + event.getClass());
-
- ClusterCreatedEvent clustercreatedEvent = (ClusterCreatedEvent) event;
-
- String serviceType = clustercreatedEvent.getCluster().getServiceName();
- //acquire read lock
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
- clustercreatedEvent.getCluster().getClusterId());
-
- try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).
- getCluster(clustercreatedEvent.getCluster().getClusterId());
- TopologyClusterInformationModel.getInstance().addCluster(cluster);
-
- } finally {
- //release read lock
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
- clustercreatedEvent.getCluster().getClusterId());
- }
-
- }
- });
-
-
- //Cluster Removed event listner
- topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- log.info("[ClusterRemovedEventListener] Received: " + event.getClass());
-
- ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event;
- TopologyClusterInformationModel.getInstance().removeCluster(clusterRemovedEvent.getClusterId());
- }
- });
-
-
- //Instance Spawned event listner
- topologyEventReceiver.addEventListener(new MemberCreatedEventListener() {
-
- @Override
- protected void onEvent(Event event) {
-
- log.info("Member created event received: " + event.getClass());
-
- MemberCreatedEvent memberCreatedEvent = (MemberCreatedEvent) event;
-
- String clusterDomain = memberCreatedEvent.getClusterId();
-
- String serviceType = memberCreatedEvent.getServiceName();
- //acquire read lock
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(memberCreatedEvent.getServiceName(),
- memberCreatedEvent.getClusterId());
-
- try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
- TopologyClusterInformationModel.getInstance().addCluster(cluster);
- } finally {
- //release read lock
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(memberCreatedEvent.getServiceName(),
- memberCreatedEvent.getClusterId());
- }
- }
- });
-
- //Member Started event listner
- topologyEventReceiver.addEventListener(new MemberStartedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- log.info("[MemberStartedEventListener] Received: " + event.getClass());
-
- MemberStartedEvent memberStartedEvent = (MemberStartedEvent) event;
-
- String clusterDomain = memberStartedEvent.getClusterId();
-
- String serviceType = memberStartedEvent.getServiceName();
- //acquire read lock
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(memberStartedEvent.getServiceName(),
- memberStartedEvent.getClusterId());
-
- try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
- TopologyClusterInformationModel.getInstance().addCluster(cluster);
- } finally {
- //release read lock
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(memberStartedEvent.getServiceName(),
- memberStartedEvent.getClusterId());
- }
-
- }
- });
-
- //Member Activated event listner
- topologyEventReceiver.addEventListener(new MemberActivatedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- log.info("[MemberActivatedEventListener] Received: " + event.getClass());
-
- MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event;
-
- String clusterDomain = memberActivatedEvent.getClusterId();
-
- String serviceType = memberActivatedEvent.getServiceName();
- //acquire read lock
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(),
- memberActivatedEvent.getClusterId());
-
- try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
- TopologyClusterInformationModel.getInstance().addCluster(cluster);
- } finally {
- //release read lock
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(),
- memberActivatedEvent.getClusterId());
- }
- }
- });
-
- // MemberReadyToShutdown
- topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() {
- @Override
- protected void onEvent(Event event) {
- log.info("[MemberReadyToShutdownEventListener] Received: " + event.getClass());
-
- MemberReadyToShutdownEvent memberReadyToShutdowEvent = (MemberReadyToShutdownEvent) event;
-
- String clusterDomain = memberReadyToShutdowEvent.getClusterId();
-
- String serviceType = memberReadyToShutdowEvent.getServiceName();
- //acquire read lock
- TopologyManager.acquireReadLock();
-
- try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
- TopologyClusterInformationModel.getInstance().addCluster(cluster);
-
- } finally {
- //release read lock
- TopologyManager.releaseReadLock();
- }
- }
- });
-
-
- //Member Suspended event listner
- topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- log.info("[MemberSuspendedEventListener] Received: " + event.getClass());
-
- MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event;
-
- String clusterDomain = memberSuspendedEvent.getClusterId();
-
- String serviceType = memberSuspendedEvent.getServiceName();
- //acquire read lock
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(memberSuspendedEvent.getServiceName(),
- memberSuspendedEvent.getClusterId());
-
- try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
- TopologyClusterInformationModel.getInstance().addCluster(cluster);
-
- } finally {
- //release read lock
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(memberSuspendedEvent.getServiceName(),
- memberSuspendedEvent.getClusterId());
- }
- }
- });
-
- //Member Terminated event listner
- topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- log.info("[MemberTerminatedEventListener] Received: " + event.getClass());
-
- MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
-
- String clusterDomain = memberTerminatedEvent.getClusterId();
-
- String serviceType = memberTerminatedEvent.getServiceName();
- //acquire read lock
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(),
- memberTerminatedEvent.getClusterId());
-
- try {
- Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
-
- // check and remove terminated member
-// if (cluster.memberExists(memberTerminatedEvent.getMemberId())) {
-// // release the read lock and acquire the write lock
-//// TopologyManager.releaseReadLock();
-//// TopologyManager.acquireWriteLock();
-// TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(),
-// memberTerminatedEvent.getClusterId());
-// TopologyManager.acquireWriteLockForCluster(memberTerminatedEvent.getServiceName(),
-// memberTerminatedEvent.getClusterId());
-//
-// try {
-// // re-check the state; another thread might have acquired the write lock and modified
-// if (cluster.memberExists(memberTerminatedEvent.getMemberId())) {
-// // remove the member from the cluster
-// Member terminatedMember = cluster.getMember(memberTerminatedEvent.getMemberId());
-// cluster.removeMember(terminatedMember);
-// if (log.isDebugEnabled()) {
-// log.debug("Removed the terminated member with id " + memberTerminatedEvent.getMemberId() + " from the cluster");
-// }
-// }
-//
-// // downgrade to read lock - 1. acquire read lock, 2. release write lock
-// // acquire read lock
-// //TopologyManager.acquireReadLock();
-// TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(),
-// memberTerminatedEvent.getClusterId());
-//
-// } finally {
-// // release the write lock
-// // TopologyManager.releaseWriteLock();
-// TopologyManager.releaseWriteLockForCluster(memberTerminatedEvent.getServiceName(),
-// memberTerminatedEvent.getClusterId());
-// }
-// }
- TopologyClusterInformationModel.getInstance().addCluster(cluster);
- } finally {
- //release read lock
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(),
- memberTerminatedEvent.getClusterId());
- }
- }
- });
-
- //add listner to Complete Topology Event
-/*
- topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- ApplicationCreatedEvent appCreateEvent = (ApplicationCreatedEvent) event;
-
- log.info("[ApplicationCreatedEventListener] Received: " + event.getClass());
-
- try {
- //TopologyManager.acquireReadLock();
- TopologyManager.acquireReadLockForApplication(appCreateEvent.getApplication().getUniqueIdentifier());
-
- // create and persist Application subscritpion
- CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager();
- ApplicationSubscription compositeAppSubscription;
- Application app = appCreateEvent.getApplication();
- String appId = app.getUniqueIdentifier();
- int tenantId = app.getTenantId();
- String domain = app.getTenantDomain();
-
- if (log.isDebugEnabled()) {
- log.debug("received application created event for app: " + appId + " and tenant: " + tenantId +
- " domain:" + domain);
- }
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(domain);
- carbonContext.setTenantId(tenantId);
- // create Application Subscription and persist
- compositeAppSubscription = cartridgeSubscriptionManager.createApplicationSubscription(appId, tenantId);
- cartridgeSubscriptionManager.persistApplicationSubscription(compositeAppSubscription);
- } catch (ApplicationSubscriptionException e) {
- log.error("failed to persist application subscription, caught exception: " + e);
- } catch (ADCException e) {
- log.error("failed to persist application subscription, caught exception: " + e);
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- // add the clusters to the topology information model
- List<Cluster> appClusters = appCreateEvent.getClusterList();
- if (appClusters != null && !appClusters.isEmpty()) {
- for (Cluster appCluster : appClusters) {
- TopologyClusterInformationModel.getInstance().addCluster(appCluster);
- }
- } else {
- log.warn("No clusters were found in the Application Created event for app id [ " +
- appId + " ] to add to Cluster Information model");
- }
-
- } finally {
- //TopologyManager.releaseReadLock();
- TopologyManager.releaseReadLockForApplication(appCreateEvent.getApplication().getUniqueIdentifier());
- }
- }
- });
-*/
-
- //add listener
-/*
- topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
- @Override
- protected void onEvent(Event event) {
-
- ApplicationTerminatedEvent appRemovedEvent = (ApplicationTerminatedEvent) event;
-
- log.info("[ApplicationTerminatedEvent] Received: " + event.getClass());
-
- try {
- // no need to lock since Topology is not accessed
- //TopologyManager.acquireReadLock();
- //TopologyManager.acquireReadLockForApplication(appRemovedEvent.getAppId());
-
- // create and persist Application subscritpion
- CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager();
- String appId = appRemovedEvent.getAppId();
-
- int tenantId = appRemovedEvent.getTenantId();
- String domain = appRemovedEvent.getTenantDomain();
-
- if (log.isDebugEnabled()) {
- log.debug("received application created event for app: " + appId + " and tenant: " + tenantId +
- " domain:" + domain);
- }
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(domain);
- carbonContext.setTenantId(tenantId);
- // create Application Subscription and persist
- cartridgeSubscriptionManager.removeApplicationSubscription(appId, tenantId);
-
- } catch (ApplicationSubscriptionException e) {
- log.error("failed to persist application subscription, caught exception: " + e);
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
- } finally {
- //TopologyManager.releaseReadLock();
- //TopologyManager.releaseReadLockForApplication(appRemovedEvent.getAppId());
- }
- }
- });
-*/
- }
-
-
- @Override
- public void run() {
-
- topologyEventReceiver.setExecutorService(executorService);
- topologyEventReceiver.execute();
- // executorService.execute(topologyEventReceiver);
-
- log.info("Stratos Manager topology receiver thread started");
-
- //Keep running till terminate is set from deactivate method of the component
- while (!terminated) {
- //loop while terminate = false
- try {
- Thread.sleep(1000);
- } catch (InterruptedException ignore) {
- }
- }
- log.info("Stratos Manager topology receiver thread terminated");
- }
-
- //terminate Topology Receiver
- public void terminate () {
- topologyEventReceiver.terminate();
- terminated = true;
- }
-
- public ExecutorService getExecutorService() {
- return executorService;
- }
-
- public void setExecutorService(ExecutorService executorService) {
- this.executorService = executorService;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/StratosUserManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/StratosUserManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/StratosUserManager.java
new file mode 100644
index 0000000..bac6970
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/StratosUserManager.java
@@ -0,0 +1,201 @@
+/*
+ * 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.manager.user.management;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.UserInfoBean;
+import org.apache.stratos.manager.user.management.exception.UserManagerException;
+import org.wso2.carbon.user.api.UserStoreException;
+import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.core.UserCoreConstants;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This Class provides the operations related to adding/updating/deleting and listing users using
+ * the carbon UserStoreManager in the particular tenant space
+ */
+public class StratosUserManager {
+
+ private transient static final Log log = LogFactory.getLog(StratosUserManager.class);
+ private static final String INTERNAL_EVERYONE_ROLE = "Internal/everyone";
+ private static final String GET_ALL_USERS_WILD_CARD = "*";
+
+ /**
+ * Add a user to the user-store of the particular tenant
+ *
+ * @param userStoreManager UserStoreManager
+ * @param userInfoBean UserInfoBean
+ * @throws UserManagerException
+ */
+ public void addUser(UserStoreManager userStoreManager, UserInfoBean userInfoBean)
+ throws UserManagerException {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Creating new User: " + userInfoBean.getUserName());
+ }
+
+ String[] roles = new String[1];
+ roles[0] = userInfoBean.getRole();
+ Map<String, String> claims = new HashMap<String, String>();
+
+ //set firstname, lastname and email as user claims
+ claims.put(UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS, userInfoBean.getEmail());
+ claims.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, userInfoBean.getFirstName());
+ claims.put(UserCoreConstants.ClaimTypeURIs.SURNAME, userInfoBean.getLastName());
+
+ try {
+ userStoreManager.addUser(userInfoBean.getUserName(), userInfoBean.getCredential(), roles, claims, userInfoBean.getProfileName());
+ } catch (UserStoreException e) {
+ String msg = "Error in adding user " + userInfoBean.getUserName() + " to User Store";
+ log.error(msg, e);
+ throw new UserManagerException(msg, e);
+ }
+
+ }
+
+ /**
+ * Delete the user with the given username in the relevant tenant space
+ *
+ * @param userStoreManager UserStoreManager
+ * @param userName UserName
+ * @throws UserManagerException
+ */
+ public void removeUser(UserStoreManager userStoreManager, String userName)
+ throws UserManagerException {
+
+ try {
+ if (userStoreManager.isExistingUser(userName)) {
+ userStoreManager.deleteUser(userName);
+ } else {
+ String msg = "Requested user " + userName + " does not exist";
+ throw new UserManagerException(msg);
+ }
+ } catch (UserStoreException e) {
+ String msg = "Error in deleting the user " + userName + " from User Store";
+ log.error(msg, e);
+ throw new UserManagerException(msg, e);
+ }
+ }
+
+
+ /**
+ * Updates the user info given the new UserInfoBean
+ *
+ * @param userStoreManager UserStoreManager
+ * @param userInfoBean UserInfoBean
+ * @throws UserManagerException
+ */
+ public void updateUser(UserStoreManager userStoreManager, UserInfoBean userInfoBean)
+ throws UserManagerException {
+
+ try {
+ if (userStoreManager.isExistingUser(userInfoBean.getUserName())) {
+ if (log.isDebugEnabled()) {
+ log.debug("Updating User " + userInfoBean.getUserName());
+ }
+
+ String[] newRoles = new String[1];
+ newRoles[0] = userInfoBean.getRole();
+
+ userStoreManager.updateRoleListOfUser(userInfoBean.getUserName(), getRefinedListOfRolesOfUser(userStoreManager, userInfoBean.getUserName()), newRoles);
+ userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS, userInfoBean.getEmail(), userInfoBean.getProfileName());
+ userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, userInfoBean.getFirstName(), userInfoBean.getProfileName());
+ userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.SURNAME, userInfoBean.getLastName(), userInfoBean.getProfileName());
+ userStoreManager.updateCredentialByAdmin(userInfoBean.getUserName(), userInfoBean.getCredential());
+ } else {
+ String msg = "Requested user " + userInfoBean.getUserName() + " does not exist";
+ throw new UserManagerException(msg);
+ }
+ } catch (UserStoreException e) {
+ String msg = "Error in updating the user " + userInfoBean.getUserName() + " in User Store";
+ log.error(msg, e);
+ throw new UserManagerException(msg, e);
+ }
+ }
+
+ /**
+ * Get a List of usernames and associated Roles as a UserInfoBean
+ *
+ * @param userStoreManager UserStoreManager
+ * @return List<UserInfoBean>
+ * @throws UserManagerException
+ */
+ public List<UserInfoBean> getAllUsers(UserStoreManager userStoreManager)
+ throws UserManagerException {
+
+ String[] users;
+ List<UserInfoBean> userList = new ArrayList<UserInfoBean>();
+
+ try {
+ users = userStoreManager.listUsers(GET_ALL_USERS_WILD_CARD, -1);
+ } catch (UserStoreException e) {
+ String msg = "Error in listing the users in User Store";
+ log.error(msg, e);
+ throw new UserManagerException(msg, e);
+ }
+
+ //Iterate through the list of users and retrieve their roles
+ for (String user : users) {
+ UserInfoBean userInfoBean = new UserInfoBean();
+ userInfoBean.setUserName(user);
+ userInfoBean.setRole(getRefinedListOfRolesOfUser(userStoreManager, user)[0]);
+ userList.add(userInfoBean);
+ }
+
+ return userList;
+ }
+
+ /**
+ * Get the List of userRoles except the Internal/everyone role
+ *
+ * @param userStoreManager UserStoreManager
+ * @param username Username of the user
+ * @return String[]
+ * @throws UserManagerException
+ */
+ private String[] getRefinedListOfRolesOfUser(UserStoreManager userStoreManager, String username)
+ throws UserManagerException {
+
+ ArrayList<String> rolesWithoutEveryoneRole = new ArrayList<String>();
+
+ try {
+ String[] allUserRoles = userStoreManager.getRoleListOfUser(username);
+
+ for (String role : allUserRoles) {
+ if (!role.equals(INTERNAL_EVERYONE_ROLE)) {
+ rolesWithoutEveryoneRole.add(role);
+ }
+ }
+ String[] rolesWithoutEveryoneRoleArray = new String[rolesWithoutEveryoneRole.size()];
+ return rolesWithoutEveryoneRole.toArray(rolesWithoutEveryoneRoleArray);
+
+ } catch (UserStoreException e) {
+ String msg = "Error in listing the roles of user " + username + " in User Store";
+ log.error(msg, e);
+ throw new UserManagerException(msg, e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java
new file mode 100644
index 0000000..0accc5e
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/TenantUserRoleManager.java
@@ -0,0 +1,119 @@
+/*
+ * 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.manager.user.management;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.TenantInfoBean;
+import org.apache.stratos.common.exception.ApacheStratosException;
+import org.apache.stratos.common.listeners.TenantMgtListener;
+import org.apache.stratos.manager.internal.ServiceReferenceHolder;
+import org.apache.stratos.manager.user.management.exception.UserManagerException;
+import org.apache.stratos.manager.utils.UserRoleCreator;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.user.api.UserStoreException;
+import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.api.UserRealm;
+
+/**
+ * Listener for Tenant create event to create a new Role
+ */
+public class TenantUserRoleManager implements TenantMgtListener {
+
+ private static final Log log = LogFactory.getLog(TenantUserRoleManager.class);
+
+ /**
+ * Create an 'user' role at tenant creation time
+ * @param tenantInfo TenantInfoBean
+ * @throws org.apache.stratos.common.exception.ApacheStratosException
+ */
+ @Override
+ public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException {
+
+ try {
+
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ carbonContext.setTenantDomain(tenantInfo.getTenantDomain());
+ carbonContext.setTenantId(tenantInfo.getTenantId());
+ //Get tenant UserRealm & UserStoreManager
+ UserRealm userRealm = ServiceReferenceHolder.getRealmService().getTenantUserRealm(tenantInfo.getTenantId());
+ UserStoreManager userStoreManager = userRealm.getUserStoreManager();
+ //Call Util class to create the user role
+
+ UserRoleCreator.createTenantUserRole(userStoreManager);
+
+ } catch (UserStoreException e) {
+ String msg = "Error while retrieving the user store for tenant: "+ tenantInfo.getTenantDomain();
+ log.error(msg, e);
+ throw new ApacheStratosException(e.getMessage(), e);
+ } catch (UserManagerException e) {
+ String msg = "Error while creating the user role in tenant: "+ tenantInfo.getTenantDomain();
+ log.error(msg, e);
+ throw new ApacheStratosException(e.getMessage(), e);
+ } finally {
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+
+ }
+
+
+ @Override
+ public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException {
+
+ }
+
+ @Override
+ public void onTenantDelete(int tenantId) {
+
+ }
+
+ @Override
+ public void onTenantRename(int tenantId, String oldDomainName, String newDomainName)
+ throws ApacheStratosException {
+
+ }
+
+ @Override
+ public void onTenantInitialActivation(int tenantId) throws ApacheStratosException {
+
+ }
+
+ @Override
+ public void onTenantActivation(int tenantId) throws ApacheStratosException {
+
+ }
+
+ @Override
+ public void onTenantDeactivation(int tenantId) throws ApacheStratosException {
+
+ }
+
+ @Override
+ public void onSubscriptionPlanChange(int tenentId, String oldPlan, String newPlan)
+ throws ApacheStratosException {
+
+ }
+
+ @Override
+ public int getListenerOrder() {
+ return 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/exception/UserManagerException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/exception/UserManagerException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/exception/UserManagerException.java
new file mode 100644
index 0000000..c76a3e2
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/management/exception/UserManagerException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.manager.user.management.exception;
+
+public class UserManagerException extends Exception {
+
+ private final String message;
+
+ public UserManagerException(String message, Throwable cause) {
+ super(message, cause);
+ this.message = message;
+ }
+
+ public UserManagerException(String message) {
+ super(message);
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java
deleted file mode 100644
index 398ecb5..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/StratosUserManager.java
+++ /dev/null
@@ -1,201 +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.manager.user.mgt;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.UserInfoBean;
-import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.user.api.UserStoreManager;
-import org.wso2.carbon.user.core.UserCoreConstants;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This Class provides the operations related to adding/updating/deleting and listing users using
- * the carbon UserStoreManager in the particular tenant space
- */
-public class StratosUserManager {
-
- private transient static final Log log = LogFactory.getLog(StratosUserManager.class);
- private static final String INTERNAL_EVERYONE_ROLE = "Internal/everyone";
- private static final String GET_ALL_USERS_WILD_CARD = "*";
-
- /**
- * Add a user to the user-store of the particular tenant
- *
- * @param userStoreManager UserStoreManager
- * @param userInfoBean UserInfoBean
- * @throws UserManagerException
- */
- public void addUser(UserStoreManager userStoreManager, UserInfoBean userInfoBean)
- throws UserManagerException {
-
- if (log.isDebugEnabled()) {
- log.debug("Creating new User: " + userInfoBean.getUserName());
- }
-
- String[] roles = new String[1];
- roles[0] = userInfoBean.getRole();
- Map<String, String> claims = new HashMap<String, String>();
-
- //set firstname, lastname and email as user claims
- claims.put(UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS, userInfoBean.getEmail());
- claims.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, userInfoBean.getFirstName());
- claims.put(UserCoreConstants.ClaimTypeURIs.SURNAME, userInfoBean.getLastName());
-
- try {
- userStoreManager.addUser(userInfoBean.getUserName(), userInfoBean.getCredential(), roles, claims, userInfoBean.getProfileName());
- } catch (UserStoreException e) {
- String msg = "Error in adding user " + userInfoBean.getUserName() + " to User Store";
- log.error(msg, e);
- throw new UserManagerException(msg, e);
- }
-
- }
-
- /**
- * Delete the user with the given username in the relevant tenant space
- *
- * @param userStoreManager UserStoreManager
- * @param userName UserName
- * @throws UserManagerException
- */
- public void removeUser(UserStoreManager userStoreManager, String userName)
- throws UserManagerException {
-
- try {
- if (userStoreManager.isExistingUser(userName)) {
- userStoreManager.deleteUser(userName);
- } else {
- String msg = "Requested user " + userName + " does not exist";
- throw new UserManagerException(msg);
- }
- } catch (UserStoreException e) {
- String msg = "Error in deleting the user " + userName + " from User Store";
- log.error(msg, e);
- throw new UserManagerException(msg, e);
- }
- }
-
-
- /**
- * Updates the user info given the new UserInfoBean
- *
- * @param userStoreManager UserStoreManager
- * @param userInfoBean UserInfoBean
- * @throws UserManagerException
- */
- public void updateUser(UserStoreManager userStoreManager, UserInfoBean userInfoBean)
- throws UserManagerException {
-
- try {
- if (userStoreManager.isExistingUser(userInfoBean.getUserName())) {
- if (log.isDebugEnabled()) {
- log.debug("Updating User " + userInfoBean.getUserName());
- }
-
- String[] newRoles = new String[1];
- newRoles[0] = userInfoBean.getRole();
-
- userStoreManager.updateRoleListOfUser(userInfoBean.getUserName(), getRefinedListOfRolesOfUser(userStoreManager, userInfoBean.getUserName()), newRoles);
- userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS, userInfoBean.getEmail(), userInfoBean.getProfileName());
- userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.GIVEN_NAME, userInfoBean.getFirstName(), userInfoBean.getProfileName());
- userStoreManager.setUserClaimValue(userInfoBean.getUserName(), UserCoreConstants.ClaimTypeURIs.SURNAME, userInfoBean.getLastName(), userInfoBean.getProfileName());
- userStoreManager.updateCredentialByAdmin(userInfoBean.getUserName(), userInfoBean.getCredential());
- } else {
- String msg = "Requested user " + userInfoBean.getUserName() + " does not exist";
- throw new UserManagerException(msg);
- }
- } catch (UserStoreException e) {
- String msg = "Error in updating the user " + userInfoBean.getUserName() + " in User Store";
- log.error(msg, e);
- throw new UserManagerException(msg, e);
- }
- }
-
- /**
- * Get a List of usernames and associated Roles as a UserInfoBean
- *
- * @param userStoreManager UserStoreManager
- * @return List<UserInfoBean>
- * @throws UserManagerException
- */
- public List<UserInfoBean> getAllUsers(UserStoreManager userStoreManager)
- throws UserManagerException {
-
- String[] users;
- List<UserInfoBean> userList = new ArrayList<UserInfoBean>();
-
- try {
- users = userStoreManager.listUsers(GET_ALL_USERS_WILD_CARD, -1);
- } catch (UserStoreException e) {
- String msg = "Error in listing the users in User Store";
- log.error(msg, e);
- throw new UserManagerException(msg, e);
- }
-
- //Iterate through the list of users and retrieve their roles
- for (String user : users) {
- UserInfoBean userInfoBean = new UserInfoBean();
- userInfoBean.setUserName(user);
- userInfoBean.setRole(getRefinedListOfRolesOfUser(userStoreManager, user)[0]);
- userList.add(userInfoBean);
- }
-
- return userList;
- }
-
- /**
- * Get the List of userRoles except the Internal/everyone role
- *
- * @param userStoreManager UserStoreManager
- * @param username Username of the user
- * @return String[]
- * @throws UserManagerException
- */
- private String[] getRefinedListOfRolesOfUser(UserStoreManager userStoreManager, String username)
- throws UserManagerException {
-
- ArrayList<String> rolesWithoutEveryoneRole = new ArrayList<String>();
-
- try {
- String[] allUserRoles = userStoreManager.getRoleListOfUser(username);
-
- for (String role : allUserRoles) {
- if (!role.equals(INTERNAL_EVERYONE_ROLE)) {
- rolesWithoutEveryoneRole.add(role);
- }
- }
- String[] rolesWithoutEveryoneRoleArray = new String[rolesWithoutEveryoneRole.size()];
- return rolesWithoutEveryoneRole.toArray(rolesWithoutEveryoneRoleArray);
-
- } catch (UserStoreException e) {
- String msg = "Error in listing the roles of user " + username + " in User Store";
- log.error(msg, e);
- throw new UserManagerException(msg, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java
deleted file mode 100644
index 0c98f73..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/user/mgt/exception/UserManagerException.java
+++ /dev/null
@@ -1,39 +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.manager.user.mgt.exception;
-
-public class UserManagerException extends Exception {
-
- private final String message;
-
- public UserManagerException(String message, Throwable cause) {
- super(message, cause);
- this.message = message;
- }
-
- public UserManagerException(String message) {
- super(message);
- this.message = message;
- }
-
- public String getMessage() {
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
index 84fb2e3..74134dd 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/ApplicationManagementUtil.java
@@ -1,4 +1,3 @@
-package org.apache.stratos.manager.utils;
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -18,18 +17,15 @@ package org.apache.stratos.manager.utils;
* specific language governing permissions and limitations
* under the License.
*
-*/
+ */
+package org.apache.stratos.manager.utils;
import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.rmi.RemoteException;
import java.text.DecimalFormat;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.engine.AxisConfiguration;
@@ -41,14 +37,14 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceCartridgeN
import org.apache.stratos.common.Properties;
import org.apache.stratos.common.Property;
import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo;
-import org.apache.stratos.manager.dao.DataCartridge;
-import org.apache.stratos.manager.dao.PortMapping;
-import org.apache.stratos.manager.dto.Policy;
-import org.apache.stratos.manager.dto.SubscriptionInfo;
+import org.apache.stratos.manager.domain.CartridgeSubscriptionInfo;
+import org.apache.stratos.manager.domain.DataCartridge;
+import org.apache.stratos.manager.domain.PortMapping;
+import org.apache.stratos.manager.domain.Policy;
+import org.apache.stratos.manager.domain.SubscriptionInfo;
import org.apache.stratos.manager.exception.ADCException;
import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.repository.Repository;
+import org.apache.stratos.manager.domain.repository.Repository;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
/**
@@ -313,8 +309,6 @@ public class ApplicationManagementUtil {
return subscriptionInfo;
}
-
-
public static void registerService(String cartridgeType, String domain, String subDomain,
StringBuilder payload, String tenantRange, String hostName,
String autoscalingPoliyName, String deploymentPolicyName,
@@ -333,7 +327,4 @@ public class ApplicationManagementUtil {
throw new ADCException("An error occurred in subscribing process", e);
}
}
-
-
-
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/CartridgeConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/CartridgeConstants.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/CartridgeConstants.java
index 89a41ca..fe5df1c 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/CartridgeConstants.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/CartridgeConstants.java
@@ -21,57 +21,19 @@ package org.apache.stratos.manager.utils;
public class CartridgeConstants {
public static final String AUTOSCALER_SERVICE_URL = "autoscaler.service.url";
- public static final String IDENTITY_SERVICE_URL = "identity.service.url";
public static final String CLOUD_CONTROLLER_SERVICE_URL = "cloud.controller.service.url";
- public static final String ALIAS_NAMESPACE ="http://org.wso2.securevault/configuration";
- public static final String ALIAS_LOCALPART ="secretAlias";
- public static final String ALIAS_PREFIX ="svns";
- public static final String SUBSCRIPTION_ACTIVE = "SUBSCRIPTION_ACTIVE";
- public static final String SUBSCRIPTION_INACTIVE = "SUBSCRIPTION_INACTIVE";
- public static final String ACTIVE = "ACTIVE";
- public static final String NOT_READY = "NOT-READY";
- public static final String SUBSCRIBED = "SUBSCRIBED";
- public static final String UNSUBSCRIBED = "UNSUBSCRIBED";
public static final String PUPPET_IP = "puppet.ip";
public static final String PUPPET_HOSTNAME = "puppet.hostname";
public static final String PUPPET_DNS_AVAILABLE = "puppet.dns.available";
public static final String PUPPET_ENVIRONMENT = "puppet.environment";
- public static final String SUDO_SH = "sudo sh";
- public static final String APPEND_SCRIPT = "append.script";
- public static final String REMOVE_SCRIPT = "remove.script";
- public static final String BIND_FILE_PATH = "bind.file.path";
-
- public static final String FEATURE_EXTERNAL_REPO_VAIDATION_ENABLED = "feature.externalrepo.validation.enabled";
- public static final String FEATURE_INTERNAL_REPO_ENABLED = "feature.internalrepo.enabled";
- public static final String FEATURE_MULTI_TENANT_MULTIPLE_SUBSCRIPTION_ENABLED = "feature.multitenant.multiplesubscription.enabled";
-
- public static final String MYSQL_CARTRIDGE_NAME = "mysql";
- public static final String PHP_CARTRIDGE_NAME = "php";
- public static final String TOMCAT_CARTRIDGE_NAME = "tomcat";
-
- public static final String DEFAULT_SUBDOMAIN = "__$default";
- public static final String DEFAULT_MGT_SUBDOMAIN = "mgt";
- public static final String MYSQL_DEFAULT_USER = "root";
- public static final String PROVIDER_NAME_WSO2 = "wso2";
- public static final String NOT_SUBSCRIBED = "NOT-SUBSCRIBED";
- public static final String SECURITY_KEY_FILE = "gitRepoKey.xml";
- public static final String SECURITY_KEY = "securityKey";
- public static final String DEFAULT_SECURITY_KEY = "tvnw63ufg9gh5111";
+ public static final String FEATURE_MULTI_TENANT_MULTIPLE_SUBSCRIPTION_ENABLED = "feature.multitenant.multiplesubscription.enabled";
public static final String DATA_CARTRIDGE_PROVIDER = "data";
- public static final String INTERNAL_GIT_USERNAME = "internal.repo.username";
- public static final String INTERNAL_GIT_PASSWORD = "internal.repo.password";
- public static final String INTERNAL_GIT_URL = "internal.git.url"; // "https://localhost:8443/"
- public static final String INTERNAL_GIT_DIR_STRUCTURE = "internal.git.dir"; // directory structure
- public static final String CUSTOM_PAYLOAD_PARAM_NAME_PREFIX = "payload_parameter.";
-
public static final String CC_SOCKET_TIMEOUT = "cc.socket.timeout";
public static final String CC_CONNECTION_TIMEOUT = "cc.connection.timeout";
public static final String AUTOSCALER_SOCKET_TIMEOUT = "autoscaler.socket.timeout";
public static final String AUTOSCALER_CONNECTION_TIMEOUT = "autoscaler.connection.timeout";
-
- public static final String COMMIT_ENABLED = "COMMIT_ENABLED";
// BAM publisher related values
public static final String BAM_PUBLISHER_ENABLED = "bam.publisher.enabled";
@@ -93,17 +55,4 @@ public class CartridgeConstants {
public static final String HOST_NAME_COL = "hostname";
public static final String MAPPED_DOMAIN_COL = "mappedDomain";
public static final String ACTION_COL = "action";
- public static final String INTERNAL_REPO_BASED_CARTRIDGE_PROVIDER = "internal";
-
- // payload data related information
- public static final String LOAD_BALANCED_SERVICE_TYPE = "LOAD_BALANCED_SERVICE_TYPE";
- public static final String LB_CATEGORY = "LB_CATEGORY";
-
- // lb cluster
- public static final String LB_CLUSTER_ID = "lbClusterId";
-
- public static final class DomainMappingInfo {
- public static final String ACTUAL_HOST = "actual.host";
- public static final String HOSTINFO = "hostinfo/";
- }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Deserializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Deserializer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Deserializer.java
deleted file mode 100644
index 3f78f3b..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Deserializer.java
+++ /dev/null
@@ -1,52 +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.manager.utils;
-
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-
-public class Deserializer {
-
-
- /**
- * Deserialize a byte array and retrieve the object.
- * @param bytes bytes to be deserialized
- * @return the deserialized {@link Object}
- * @throws Exception if the deserialization is failed.
- */
- public static Object deserializeFromByteArray(byte[] bytes) throws Exception {
-
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- ObjectInput in = null;
- try {
- in = new ObjectInputStream(bis);
- Object o = in.readObject();
-
- return o;
-
- } finally {
- bis.close();
- if (in != null) {
- in.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/PolicyHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/PolicyHolder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/PolicyHolder.java
deleted file mode 100644
index 98ddd3d..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/PolicyHolder.java
+++ /dev/null
@@ -1,292 +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.manager.utils;
-
-import java.io.File;
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
-import javax.xml.validation.Validator;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
-import org.apache.axiom.om.impl.dom.ElementImpl;
-import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.dto.Policy;
-import org.apache.stratos.manager.dto.PolicyDefinition;
-import org.jaxen.JaxenException;
-import org.w3c.dom.Element;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.xml.sax.SAXException;
-
-import com.google.gson.Gson;
-
-public class PolicyHolder {
-
- private static Log log = LogFactory.getLog(PolicyHolder.class);
-
- private static final String POLICIES_ELEMENT = "policies";
- private static final String POLICY_ELEMENT = "policy";
-
- private static final String POLICIES_ELEMENT_XPATH = "/" + POLICIES_ELEMENT + "/" + POLICY_ELEMENT;
-
- private static final String NAME_ATTR = "name";
- private static final String IS_DEFAULT_ATTR = "isDefault";
- private static final String DESCRIPTION_ELEMENT = "description";
- private static final String MIN_APP_INSTANCES_ELEMENT = "min_app_instances";
- private static final String MAX_APP_INSTANCES_ELEMENT = "max_app_instances";
- private static final String MAX_REQUESTS_PER_SECOND_ELEMENT = "max_requests_per_second";
- private static final String ALARMING_UPPER_RATE_ELEMENT = "alarming_upper_rate";
- private static final String ALARMING_LOWER_RATE_ELEMENT = "alarming_lower_rate";
- private static final String SCALE_DOWN_FACTOR_ELEMENT = "scale_down_factor";
- private static final String ROUNDS_TO_AVERAGE_ELEMENT = "rounds_to_average";
-
- private Map<String, Policy> policyMap = new HashMap<String, Policy>();
-
- private Policy defaultPolicy;
-
- private List<PolicyDefinition> policyDefinitions = new ArrayList<PolicyDefinition>();
-
- private PolicyHolder(File policiesSchema, File policiesXML) {
- try {
- readPolicies(policiesSchema, policiesXML);
- } catch (Exception e) {
- log.error("Error reading policies", e);
- }
- }
-
- private static class SingletonHolder {
- private final static PolicyHolder INSTANCE = new PolicyHolder(new File(CarbonUtils.getCarbonConfigDirPath()
- + File.separator + "etc" + File.separator, "policies.xsd"), new File(
- CarbonUtils.getCarbonConfigDirPath(), "policies.xml"));
- }
-
- public static PolicyHolder getInstance() {
- return SingletonHolder.INSTANCE;
- }
-
- public Policy getPolicy(String policyName) {
- return policyMap.get(policyName);
- }
-
- public Policy getDefaultPolicy() {
- return defaultPolicy;
- }
-
- public List<PolicyDefinition> getPolicyDefinitions() {
- return policyDefinitions;
- }
-
- private void readPolicies(File policiesSchema, File policiesXML) throws XMLStreamException, JaxenException,
- SAXException, IOException {
- if (log.isDebugEnabled()) {
- log.debug("Policies schema: " + policiesSchema.getPath());
- log.debug("Loading policies from file: " + policiesXML.getPath());
- }
- OMElement documentElement;
- if (policiesXML.exists()) {
- documentElement = new StAXOMBuilder(policiesXML.getPath()).getDocumentElement();
- } else {
- throw new IllegalStateException("Policies file cannot be found : " + policiesXML.getPath());
- }
-
- // Validate XML
- validate(documentElement, policiesSchema);
-
- String xpath = POLICIES_ELEMENT_XPATH;
-
- AXIOMXPath axiomXpath;
- axiomXpath = new AXIOMXPath(xpath);
- @SuppressWarnings("unchecked")
- List<OMNode> policyNodes = axiomXpath.selectNodes(documentElement);
-
- if (policyNodes == null || policyNodes.isEmpty()) {
- log.warn("No policies found in the file : " + policiesXML.getPath());
- return;
- }
-
- for (OMNode policyNode : policyNodes) {
-
- if (policyNode.getType() == OMNode.ELEMENT_NODE) {
-
- OMElement policyElement = (OMElement) policyNode;
-
- try {
- readPolicy(policyElement);
- } catch (Exception e) {
- log.error("Error reading policy", e);
- }
- }
- }
- }
-
- private void readPolicy(OMElement policyElement) {
- // retrieve attributes
- String name = policyElement.getAttributeValue(new QName(NAME_ATTR));
- boolean isDefault = Boolean.valueOf(policyElement.getAttributeValue(new QName(IS_DEFAULT_ATTR)));
-
- Policy policy = new Policy();
- policy.setName(name);
- policy.setDefaultPolicy(isDefault);
-
- // read description
- Iterator<?> it = policyElement.getChildrenWithName(new QName(DESCRIPTION_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setDescription(element.getText());
- }
-
- // read min_app_instances
- it = policyElement.getChildrenWithName(new QName(MIN_APP_INSTANCES_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setMinAppInstances(Integer.parseInt(element.getText()));
- }
-
- // read max_app_instances
- it = policyElement.getChildrenWithName(new QName(MAX_APP_INSTANCES_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setMaxAppInstances(Integer.parseInt(element.getText()));
- }
-
- // read max_requests_per_second
- it = policyElement.getChildrenWithName(new QName(MAX_REQUESTS_PER_SECOND_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setMaxRequestsPerSecond(Integer.parseInt(element.getText()));
- }
-
- // read rounds_to_average
- it = policyElement.getChildrenWithName(new QName(ROUNDS_TO_AVERAGE_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setRoundsToAverage(Integer.parseInt(element.getText()));
- }
-
- // read alarming_upper_rate
- it = policyElement.getChildrenWithName(new QName(ALARMING_UPPER_RATE_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setAlarmingUpperRate(new BigDecimal(element.getText()));
- }
-
- // read alarming_lower_rate
- it = policyElement.getChildrenWithName(new QName(ALARMING_LOWER_RATE_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setAlarmingLowerRate(new BigDecimal(element.getText()));
- }
-
- // read scale_down_factor
- it = policyElement.getChildrenWithName(new QName(SCALE_DOWN_FACTOR_ELEMENT));
-
- if (it.hasNext()) {
- OMElement element = (OMElement) it.next();
- policy.setScaleDownFactor(new BigDecimal(element.getText()));
- }
- if (log.isDebugEnabled()) {
- log.debug("Policy: " + new Gson().toJson(policy));
- }
-
- policyMap.put(policy.getName(), policy);
- PolicyDefinition policyDefinition = new PolicyDefinition();
- policyDefinition.setName(policy.getName());
- policyDefinition.setDescription(policy.getDescription());
- policyDefinition.setDefaultPolicy(policy.isDefaultPolicy());
- policyDefinitions.add(policyDefinition);
-
- // Set first default policy
- if (defaultPolicy == null && policy.isDefaultPolicy()) {
- defaultPolicy = policy;
- }
- }
-
- // TODO Following code is copied from
- // org.wso2.carbon.stratos.cloud.controller.axiom.AxiomXpathParser
- // There should be a common util to validate XML using a schema.
- public void validate(final OMElement omElement, final File schemaFile) throws SAXException, IOException {
-
- Element sourceElement;
-
- // if the OMElement is created using DOM implementation use it
- if (omElement instanceof ElementImpl) {
- sourceElement = (Element) omElement;
- } else { // else convert from llom to dom
- sourceElement = getDOMElement(omElement);
- }
-
- // Create a SchemaFactory capable of understanding WXS schemas.
-
- // Load a WXS schema, represented by a Schema subscription.
- SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Source source = new StreamSource(schemaFile);
-
- // Create a Validator object, which can be used to validate
- // an subscription document.
- Schema schema = factory.newSchema(source);
- Validator validator = schema.newValidator();
-
- // Validate the DOM tree.
- validator.validate(new DOMSource(sourceElement));
- }
-
- private Element getDOMElement(final OMElement omElement) {
-
- // Get the StAX reader from the created element
- XMLStreamReader llomReader = omElement.getXMLStreamReader();
-
- // Create the DOOM OMFactory
- OMFactory doomFactory = DOOMAbstractFactory.getOMFactory();
-
- // Create the new builder
- StAXOMBuilder doomBuilder = new StAXOMBuilder(doomFactory, llomReader);
-
- // Get the document element
- OMElement newElem = doomBuilder.getDocumentElement();
-
- return newElem instanceof Element ? (Element) newElem : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepoPasswordMgtUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepoPasswordMgtUtil.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepoPasswordMgtUtil.java
deleted file mode 100644
index cac4f82..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepoPasswordMgtUtil.java
+++ /dev/null
@@ -1,121 +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.manager.utils;
-
-import javax.crypto.Cipher;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class RepoPasswordMgtUtil {
-
- private static final Log log = LogFactory.getLog(RepoPasswordMgtUtil.class);
-
- public static String getSecurityKey() {
- // TODO : a proper testing on the secure vault protected
- // user defined encryption key
- String securityKey = CartridgeConstants.DEFAULT_SECURITY_KEY;
- /*OMElement documentElement = null;
- File xmlFile = new File(CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf"
- + File.separator + CartridgeConstants.SECURITY_KEY_FILE);
-
- if (xmlFile.exists()) {
- try {
- documentElement = new StAXOMBuilder(xmlFile.getPath()).getDocumentElement();
- } catch (Exception ex) {
- String msg = "Error occurred when parsing the " + xmlFile.getPath() + ".";
- log.error(msg, ex);
- ex.printStackTrace();
- }
- if (documentElement != null) {
- Iterator<?> it = documentElement.getChildrenWithName(new QName(CartridgeConstants.SECURITY_KEY));
- if (it.hasNext()) {
- OMElement securityKeyElement = (OMElement) it.next();
- SecretResolver secretResolver = SecretResolverFactory.create(documentElement, false);
- String alias = securityKeyElement.getAttributeValue(new QName(CartridgeConstants.ALIAS_NAMESPACE,
- CartridgeConstants.ALIAS_LOCALPART, CartridgeConstants.ALIAS_PREFIX));
-
- if (secretResolver != null && secretResolver.isInitialized()
- && secretResolver.isTokenProtected(alias)) {
- securityKey = "";
- securityKey = secretResolver.resolve(alias);
-
- }
- }
- }
- }
- else {
- log.error(String.format("File does not exist: %s", xmlFile.getPath()));
- }*/
- return securityKey;
- }
-
- public static String encryptPassword(String repoUserPassword, String secKey) {
- String encryptPassword = "";
- String secret = secKey; // secret key length must be 16
- SecretKey key;
- Cipher cipher;
- Base64 coder;
- key = new SecretKeySpec(secret.getBytes(), "AES");
- try {
- cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE");
- coder = new Base64();
- cipher.init(Cipher.ENCRYPT_MODE, key);
- byte[] cipherText = cipher.doFinal(repoUserPassword.getBytes());
- encryptPassword = new String(coder.encode(cipherText));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return encryptPassword;
- }
-
- public static String encryptPassword(String repoUserPassword) {
- return encryptPassword(repoUserPassword,getSecurityKey());
- }
-
- public static String decryptPassword(String repoUserPassword, String secKey) {
-
- String decryptPassword = "";
- String secret = secKey; // secret key length must be 16
- SecretKey key;
- Cipher cipher;
- Base64 coder;
- key = new SecretKeySpec(secret.getBytes(), "AES");
- try {
- cipher = Cipher.getInstance("AES/ECB/PKCS5Padding", "SunJCE");
- coder = new Base64();
- byte[] encrypted = coder.decode(repoUserPassword.getBytes());
- cipher.init(Cipher.DECRYPT_MODE, key);
- byte[] decrypted = cipher.doFinal(encrypted);
- decryptPassword = new String(decrypted);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return decryptPassword;
- }
-
- public static String decryptPassword(String repoUserPassword) {
- return decryptPassword(repoUserPassword,getSecurityKey());
- }
-}
[12/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/data/DataCartridgeSubscriptionConnector.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/data/DataCartridgeSubscriptionConnector.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/data/DataCartridgeSubscriptionConnector.java
deleted file mode 100644
index b376da4..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/data/DataCartridgeSubscriptionConnector.java
+++ /dev/null
@@ -1,88 +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.manager.connector.data;
-
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.connector.CartridgeSubscriptionConnector;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-public class DataCartridgeSubscriptionConnector extends CartridgeSubscriptionConnector {
-
- private static Log log = LogFactory.getLog(DataCartridgeSubscriptionConnector.class);
-
- @Override
- public Properties createConnection(CartridgeSubscription cartridgeSubscription,
- CartridgeSubscription connectingCartridgeSubscription) throws ADCException {
-
- //TODO: change the logic to do with topology information
- log.info("Retrieving cartridge information for connecting ... alias : " +
- connectingCartridgeSubscription.getAlias() + ", Type: " + connectingCartridgeSubscription.getType());
-
- Properties connectionProperties = new Properties();
-
- // int maxAttempts = Integer.parseInt(System.getProperty(CartridgeConstants.MAX_ATTEMPTS, "50"));
- //int attempts = 0;
- // while (attempts < maxAttempts) {
- //attempts++;
- /*Cartridge cartridge = null;
- try {
- cartridge = ApplicationManagementUtil.getCartridgeInfo(
- connectingCartridgeSubscription.getAlias(),
- connectingCartridgeSubscription.getSubscriber().getTenantDomain());
-
- } catch (NotSubscribedException e) {
-
- }*/
- //if (cartridge != null) {
- /*if (!cartridge.getStatus().equals("ACTIVE")) {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException ignore) {
- }
- } else {
- connectionProperties.setProperty("MYSQL_HOST", cartridge.getIp());
- connectionProperties.setProperty("MYSQL_USER", cartridge.getDbUserName());
- connectionProperties.setProperty("MYSQL_PASSWORD", cartridge.getPassword());
- log.info("Connection information retrieved for " + cartridgeSubscription + " and " +
- connectingCartridgeSubscription);
- break;
- }*/
- //}
-
- /*if(attempts == maxAttempts) {
- String errorMsg = "Failed to connect " + cartridgeSubscription + " and " + connectingCartridgeSubscription;
- log.error(errorMsg);
- throw new ADCException(errorMsg);
- }*/
- //}
-
- return connectionProperties;
- }
-
- @Override
- public Properties teminateConnection(CartridgeSubscription cartridgeSubscription,
- CartridgeSubscription connectedCartridgeSubscription) throws ADCException {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/CartridgeSubscriptionInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/CartridgeSubscriptionInfo.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/CartridgeSubscriptionInfo.java
deleted file mode 100644
index eb48d0e..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/CartridgeSubscriptionInfo.java
+++ /dev/null
@@ -1,200 +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.manager.dao;
-
-import org.apache.stratos.manager.repository.Repository;
-
-import java.util.List;
-
-public class CartridgeSubscriptionInfo {
-
- private int subscriptionId;
- private int tenantId;
- private String cartridge;
- private String provider;
- private String hostName;
- private String policy;
- private List<PortMapping> portMappings;
- private String clusterDomain;
- private String clusterSubdomain;
- private Repository repository;
- private String state;
- private String alias;
- private String tenantDomain;
- private DataCartridge dataCartridge;
- private String baseDirectory;
- private String mappedDomain;
- private String mgtClusterDomain;
- private String mgtClusterSubDomain;
- private String subscriptionKey;
-
- public int getSubscriptionId() {
- return subscriptionId;
- }
-
- public void setSubscriptionId(int subscriptionId) {
- this.subscriptionId = subscriptionId;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getCartridge() {
- return cartridge;
- }
-
- public void setCartridge(String cartridge) {
- this.cartridge = cartridge;
- }
-
- public String getProvider() {
- return provider;
- }
-
- public void setProvider(String provider) {
- this.provider = provider;
- }
-
- public String getHostName() {
- return hostName;
- }
-
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
-
- public String getPolicy() {
- return policy;
- }
-
- public void setPolicy(String policy) {
- this.policy = policy;
- }
-
- public List<PortMapping> getPortMappings() {
- return portMappings;
- }
-
- public void setPortMappings(List<PortMapping> portMappings) {
- this.portMappings = portMappings;
- }
-
- public String getClusterDomain() {
- return clusterDomain;
- }
-
- public void setClusterDomain(String clusterDomain) {
- this.clusterDomain = clusterDomain;
- }
-
- public String getClusterSubdomain() {
- return clusterSubdomain;
- }
-
- public void setClusterSubdomain(String clusterSubdomain) {
- this.clusterSubdomain = clusterSubdomain;
- }
-
- public Repository getRepository() {
- return repository;
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
- public String getState() {
- return state;
- }
-
- public void setState(String state) {
- this.state = state;
- }
-
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public String getTenantDomain() {
- return tenantDomain;
- }
-
- public void setTenantDomain(String tenantDomain) {
- this.tenantDomain = tenantDomain;
- }
-
- public DataCartridge getDataCartridge() {
- return dataCartridge;
- }
-
- public void setDataCartridge(DataCartridge dataCartridge) {
- this.dataCartridge = dataCartridge;
- }
-
- public String getBaseDirectory() {
- return baseDirectory;
- }
-
- public void setBaseDirectory(String baseDirectory) {
- this.baseDirectory = baseDirectory;
- }
-
- public String getMappedDomain() {
- return mappedDomain;
- }
-
- public void setMappedDomain(String mappedDomain) {
- this.mappedDomain = mappedDomain;
- }
-
- public String getMgtClusterDomain() {
- return mgtClusterDomain;
- }
-
- public void setMgtClusterDomain(String mgtClusterDomain) {
- this.mgtClusterDomain = mgtClusterDomain;
- }
-
- public String getMgtClusterSubDomain() {
- return mgtClusterSubDomain;
- }
-
- public void setMgtClusterSubDomain(String mgtClusterSubDomain) {
- this.mgtClusterSubDomain = mgtClusterSubDomain;
- }
-
- public String getSubscriptionKey() {
- return subscriptionKey;
- }
-
- public void setSubscriptionKey(String subscriptionKey) {
- this.subscriptionKey = subscriptionKey;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/Cluster.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/Cluster.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/Cluster.java
deleted file mode 100644
index 98f7029..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/Cluster.java
+++ /dev/null
@@ -1,97 +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.manager.dao;
-
-import java.io.Serializable;
-
-public class Cluster implements Serializable {
- private static final long serialVersionUID = -1579127946734432357L;
- private int id;
- private String clusterDomain;
- private String clusterSubDomain;
- private String mgtClusterDomain;
- private String mgtClusterSubDomain;
- private String hostName;
- private String serviceStatus;
-
- public Cluster() {
- }
-
- public String getHostName() {
- return hostName;
- }
-
- public String getClusterDomain() {
- return clusterDomain;
- }
-
- public void setClusterDomain(String clusterDomain) {
- this.clusterDomain = clusterDomain;
- }
-
- public String getClusterSubDomain() {
- return clusterSubDomain;
- }
-
- public void setClusterSubDomain(String clusterSubDomain) {
- this.clusterSubDomain = clusterSubDomain;
- }
-
- public String getMgtClusterDomain() {
- return mgtClusterDomain;
- }
-
- public void setMgtClusterDomain(String mgtClusterDomain) {
- this.mgtClusterDomain = mgtClusterDomain;
- }
-
- public String getMgtClusterSubDomain() {
- return mgtClusterSubDomain;
- }
-
- public void setMgtClusterSubDomain(String mgtClusterSubDomain) {
- this.mgtClusterSubDomain = mgtClusterSubDomain;
- }
-
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getServiceStatus() {
- return serviceStatus;
- }
-
- public void setServiceStatus(String serviceStatus) {
- this.serviceStatus = serviceStatus;
- }
-
- public String toString () {
- return clusterDomain;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/DataCartridge.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/DataCartridge.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/DataCartridge.java
deleted file mode 100644
index d6fd2d8..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/DataCartridge.java
+++ /dev/null
@@ -1,62 +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.manager.dao;
-
-public class DataCartridge {
-
- private int id;
- private String dataCartridgeType;
- private String host;
- private String userName;
- private String password;
-
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public String getDataCartridgeType() {
- return dataCartridgeType;
- }
- public void setDataCartridgeType(String dataCartridgeType) {
- this.dataCartridgeType = dataCartridgeType;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/PortMapping.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/PortMapping.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/PortMapping.java
deleted file mode 100644
index d59913d..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/PortMapping.java
+++ /dev/null
@@ -1,59 +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.manager.dao;
-
-public class PortMapping {
- private int id;
- private String type;
- private String primaryPort;
- private String proxyPort;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getPrimaryPort() {
- return primaryPort;
- }
-
- public void setPrimaryPort(String primaryPort) {
- this.primaryPort = primaryPort;
- }
-
- public String getProxyPort() {
- return proxyPort;
- }
-
- public void setProxyPort(String proxyPort) {
- this.proxyPort = proxyPort;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/RepositoryCredentials.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/RepositoryCredentials.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/RepositoryCredentials.java
deleted file mode 100644
index 5952f82..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dao/RepositoryCredentials.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.apache.stratos.manager.dao;
-/*
- *
- * 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.
- *
-*/
-
-
-public class RepositoryCredentials {
-
- private String url;
- private String userName;
- private String password;
- public String getUrl() {
- return url;
- }
- public void setUrl(String url) {
- this.url = url;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeployer.java
deleted file mode 100644
index 0d1a8ea..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeployer.java
+++ /dev/null
@@ -1,38 +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.manager.deploy.cartridge;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeConfig;
-import org.apache.stratos.manager.exception.ADCException;
-
-public abstract class CartridgeDeployer {
-
- public final void deploy(CartridgeConfig cartridgeConfig) throws ADCException {
- preDeployment();
- deployCartridge(cartridgeConfig);
- postDeployment();
- }
-
- protected abstract void preDeployment();
-
- protected abstract void deployCartridge(CartridgeConfig cartridgeConfig) throws ADCException;
-
- protected abstract void postDeployment();
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeploymentManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeploymentManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeploymentManager.java
deleted file mode 100644
index 915755e..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/CartridgeDeploymentManager.java
+++ /dev/null
@@ -1,26 +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.manager.deploy.cartridge;
-
-public class CartridgeDeploymentManager {
-
- public static CartridgeDeployer getDeploymentManager() {
- return new DefaultCartridgeDeployer();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DefaultCartridgeDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DefaultCartridgeDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DefaultCartridgeDeployer.java
deleted file mode 100644
index a5699f0..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DefaultCartridgeDeployer.java
+++ /dev/null
@@ -1,50 +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.manager.deploy.cartridge;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeConfig;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.exception.ADCException;
-
-public class DefaultCartridgeDeployer extends CartridgeDeployer {
-
- private static Log log = LogFactory.getLog(DefaultCartridgeDeployer.class);
-
- @Override
- protected void preDeployment() {
- }
-
- @Override
- protected void postDeployment() {
- }
-
- @Override
- protected void deployCartridge(CartridgeConfig cartridgeConfig) throws ADCException {
- try {
- CloudControllerServiceClient cloudControllerServiceClient = CloudControllerServiceClient.getServiceClient();
- cloudControllerServiceClient.addCartridge(cartridgeConfig);
- } catch (Exception e) {
- String msg = "Could not deploy cartridge";
- log.error(msg, e);
- throw new ADCException(msg);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DockerCartridgeDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DockerCartridgeDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DockerCartridgeDeployer.java
deleted file mode 100644
index ab90842..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/cartridge/DockerCartridgeDeployer.java
+++ /dev/null
@@ -1,39 +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.manager.deploy.cartridge;
-
-
-public class DockerCartridgeDeployer extends DefaultCartridgeDeployer {
-
-
- @Override
- protected void preDeployment() {
- // Check image availability
- // If image not there invoke jenkins to build image
-
- }
-
- @Override
- protected void postDeployment() {
- // TODO Auto-generated method stub
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
deleted file mode 100644
index c5fb786..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/Service.java
+++ /dev/null
@@ -1,192 +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.manager.deploy.service;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.NotSubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils;
-
-public abstract class Service extends CartridgeMgtBehaviour {
-
- private static final long serialVersionUID = -3261972002698749232L;
-
- private String type;
- private String autoscalingPolicyName;
- private String deploymentPolicyName;
- private String tenantRange;
- private int tenantId;
- private String subscriptionKey;
- private CartridgeInfo cartridgeInfo;
- private PayloadData payloadData;
- private Cluster cluster;
- private boolean isPublic;
-
- public Service (String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId, CartridgeInfo cartridgeInfo,
- String tenantRange, boolean isPublic) {
-
- this.type = type;
- this.autoscalingPolicyName = autoscalingPolicyName;
- this.deploymentPolicyName = deploymentPolicyName;
- this.tenantId = tenantId;
- this.cartridgeInfo = cartridgeInfo;
- this.tenantRange = tenantRange;
- this.subscriptionKey = CartridgeSubscriptionUtils.generateSubscriptionKey();
- this.setCluster(new Cluster());
- this.isPublic = isPublic;
- }
-
- public void create () throws ADCException {
-
- setClusterId(generateClusterId(null, type));
- //host name is the hostname defined in cartridge definition
- setHostName(generateHostName(null, cartridgeInfo.getHostName()));
-
- // create and set PayloadData instance
- setPayloadData(createPayload(cartridgeInfo, subscriptionKey, null, cluster, null, null, null));
- }
-
- protected String generateClusterId (String alias, String cartridgeType) {
-
- String clusterId = cartridgeType + "." + cartridgeInfo.getHostName() + ".domain";
- // limit the cartridge alias to 30 characters in length
- if (clusterId.length() > 30) {
- clusterId = CartridgeSubscriptionUtils.limitLengthOfString(clusterId, 30);
- }
-
- return clusterId;
- }
-
- protected String generateHostName (String alias, String cartridgeDefinitionHostName) {
-
- return cartridgeDefinitionHostName;
- }
-
- public void deploy (Properties properties) throws ADCException, UnregisteredCartridgeException {
-
- register(getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), getDeploymentPolicyName(), properties, null);
- }
-
- public void undeploy () throws ADCException, NotSubscribedException {
-
- remove(cluster.getClusterDomain(), null);
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getAutoscalingPolicyName() {
- return autoscalingPolicyName;
- }
-
- public void setAutoscalingPolicyName(String autoscalingPolicyName) {
- this.autoscalingPolicyName = autoscalingPolicyName;
- }
-
- 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 String getClusterId() {
- return cluster.getClusterDomain();
- }
-
- public void setClusterId(String clusterId) {
- this.cluster.setClusterDomain(clusterId);
- }
-
- public String getHostName() {
- return cluster.getHostName();
- }
-
- public void setHostName(String hostName) {
- this.cluster.setHostName(hostName);
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public CartridgeInfo getCartridgeInfo() {
- return cartridgeInfo;
- }
-
- public void setCartridgeInfo(CartridgeInfo cartridgeInfo) {
- this.cartridgeInfo = cartridgeInfo;
- }
-
- public String getSubscriptionKey() {
- return subscriptionKey;
- }
-
- public void setSubscriptionKey(String subscriptionKey) {
- this.subscriptionKey = subscriptionKey;
- }
-
- public PayloadData getPayloadData() {
- return payloadData;
- }
-
- public void setPayloadData(PayloadData payloadData) {
- this.payloadData = payloadData;
- }
-
- public Cluster getCluster() {
- return cluster;
- }
-
- public void setCluster(Cluster cluster) {
- this.cluster = cluster;
- }
-
- public boolean getIsPublic() {
- return isPublic;
- }
-
- public void setIsPublic(boolean isPublic) {
- this.isPublic = isPublic;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
deleted file mode 100644
index 1ceff80..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/ServiceDeploymentManager.java
+++ /dev/null
@@ -1,507 +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.manager.deploy.service;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.CloudControllerServiceCartridgeNotFoundExceptionException;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.LoadbalancerConfig;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.common.Property;
-import org.apache.stratos.common.constants.StratosConstants;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.deploy.service.multitenant.MultiTenantService;
-import org.apache.stratos.manager.deploy.service.multitenant.lb.DefaultLBService;
-import org.apache.stratos.manager.deploy.service.multitenant.lb.ExistingLBService;
-import org.apache.stratos.manager.deploy.service.multitenant.lb.LBService;
-import org.apache.stratos.manager.deploy.service.multitenant.lb.ServiceAwareLBService;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.lb.category.*;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-import java.util.Collection;
-
-public class ServiceDeploymentManager {
-
- private static Log log = LogFactory.getLog(ServiceDeploymentManager.class);
-
- public Service deployService (String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId, String tenantRange,
- String tenantDomain, String userName, boolean isPublic)
- throws ADCException, UnregisteredCartridgeException, ServiceAlreadyDeployedException {
-
- //check if already we have a Multitenant service deployed for the same type
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-
- Service deployedService;
- try {
- deployedService = dataInsertionAndRetrievalManager.getService(type);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in checking if Service is available is PersistenceManager";
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
-
- if (deployedService != null) {
- String errorMsg = "There is an already deployed Service for type " + type;
- log.error(errorMsg);
- throw new ServiceAlreadyDeployedException(errorMsg, type);
- }
-
- //get deployed Cartridge Definition information
- CartridgeInfo cartridgeInfo;
- try {
- cartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(type);
-
- } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
- String message = type + " is not a valid cartridgeSubscription type. Please try again with a valid cartridgeSubscription type.";
- log.error(message);
- throw new ADCException(message, e);
-
- } catch (Exception e) {
- String message = "Error getting info for " + type;
- log.error(message, e);
- throw new ADCException(message, e);
- }
-
- if (!cartridgeInfo.getMultiTenant()) {
- String errorMsg = "Cartridge definition with type " + type + " is not multitenant";
- log.error(errorMsg);
- throw new ADCException(errorMsg);
- }
-
-
-// // TODO - LB cartridge.... ??
-//
-// List<Property> lbRefProp = new ArrayList<Property>();
-//
-// // get lb config reference
-// LoadbalancerConfig lbConfig = cartridgeInfo.getLbConfig();
-//
-// if (lbConfig == null || lbConfig.getProperties() == null) {
-//
-// if (log.isDebugEnabled()) {
-// log.debug("This Service does not require a load balancer. " + "[Service Name] " +
-// type);
-// }
-// } else {
-//
-// Service lbService;
-//
-// Properties lbReferenceProperties = lbConfig.getProperties();
-//
-// Property property = new Property();
-// property.setName(org.apache.stratos.messaging.util.Constants.LOAD_BALANCER_REF);
-//
-// for (org.apache.stratos.cloud.controller.pojo.Property prop : lbReferenceProperties.getProperties()) {
-//
-// String name = prop.getName();
-// String value = prop.getValue();
-//
-// // TODO make following a chain of responsibility pattern
-// if (Constants.NO_LOAD_BALANCER.equals(name)) {
-// if ("true".equals(value)) {
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge does not require a load balancer. " +
-// "[Type] " + type);
-// }
-// property.setValue(name);
-// lbRefProp.add(property);
-// break;
-// }
-// } else if (Constants.EXISTING_LOAD_BALANCERS.equals(name)) {
-// String clusterIdsVal = value;
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge refers to existing load balancers. " + "[Type] " +
-// type + "[Referenced Cluster Ids] " + clusterIdsVal);
-// }
-//
-// String[] clusterIds = clusterIdsVal.split(",");
-//
-// for (String clusterId : clusterIds) {
-//
-// try {
-// AutoscalerServiceClient.getServiceClient().checkLBExistenceAgainstPolicy(clusterId,
-// deploymentPolicyName);
-// } catch (Exception ex) {
-// // we don't need to throw the error here.
-// log.error(ex.getMessage(), ex);
-// }
-//
-// }
-//
-// property.setValue(name);
-// lbRefProp.add(property);
-// break;
-//
-// } else if (Constants.DEFAULT_LOAD_BALANCER.equals(name)) {
-//
-// if ("true".equals(value)) {
-//
-// CartridgeInfo lbCartridgeInfo;
-// String lbCartridgeType = lbConfig.getType();
-// try {
-// // retrieve lb Cartridge info
-// lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
-// } catch (Exception e) {
-// String msg = "Cannot get cartridge info: " + type;
-// log.error(msg, e);
-// throw new ADCException(msg, e);
-// }
-//
-// property.setValue(name);
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge uses default load balancer. " + "[Type] " +
-// type);
-// }
-//
-// try {
-// // get the valid policies for lb cartridge
-// DeploymentPolicy[] lbCartridgeDepPolicies =
-// AutoscalerServiceClient.getServiceClient().getDeploymentPolicies(lbCartridgeType);
-// // traverse deployment policies of lb cartridge
-// for (DeploymentPolicy policy : lbCartridgeDepPolicies) {
-// // check existence of the subscribed policy
-// if (deploymentPolicyName.equals(policy.getId())) {
-//
-// if (!AutoscalerServiceClient.getServiceClient().checkDefaultLBExistenceAgainstPolicy(deploymentPolicyName)) {
-//
-// // if lb cluster doesn't exist
-// lbService = new LBService(lbCartridgeType,
-// lbCartridgeInfo.getDefaultAutoscalingPolicy(),
-// deploymentPolicyName, tenantId,
-// lbCartridgeInfo,
-// tenantRange);
-//
-// Properties lbDeploymentProperties = new Properties();
-//
-// // check if there are properties in LB cartridge info
-// Property [] cartridgeInfoProps = lbCartridgeInfo.getProperties();
-// if (cartridgeInfoProps != null && cartridgeInfoProps.length > 0) {
-// lbDeploymentProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{property}));
-// } else {
-// lbDeploymentProperties.setProperties(new Property[]{property});
-// }
-//
-// lbService.deploy(lbDeploymentProperties);
-//
-// // persist
-// persist(lbService);
-// }
-// }
-// }
-//
-// } catch (Exception ex) {
-// // we don't need to throw the error here.
-// log.error(ex.getMessage(), ex);
-// }
-//
-//
-// lbRefProp.add(property);
-// break;
-// }
-// } else if (Constants.SERVICE_AWARE_LOAD_BALANCER.equals(name)) {
-//
-// if ("true".equals(value)) {
-//
-// CartridgeInfo lbCartridgeInfo;
-// String lbCartridgeType = lbConfig.getType();
-// try {
-// // retrieve lb Cartridge info
-// lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
-// } catch (Exception e) {
-// String msg = "Cannot get cartridge info: " + type;
-// log.error(msg, e);
-// throw new ADCException(msg, e);
-// }
-//
-// property.setValue(name);
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge uses a service aware load balancer. " +
-// "[Type] " + type);
-// }
-//
-// // add a property for the service type
-// Property loadBalancedServiceTypeProperty = new Property();
-// loadBalancedServiceTypeProperty.setName(Constants.LOAD_BALANCED_SERVICE_TYPE);
-// loadBalancedServiceTypeProperty.setValue(type);
-//
-// try {
-//
-// // get the valid policies for lb cartridge
-// DeploymentPolicy[] lbCartridgeDepPolicies =
-// AutoscalerServiceClient.getServiceClient().getDeploymentPolicies(lbCartridgeType);
-// // traverse deployment policies of lb cartridge
-// for (DeploymentPolicy policy : lbCartridgeDepPolicies) {
-//
-// // check existence of the subscribed policy
-// if (deploymentPolicyName.equals(policy.getId())) {
-//
-// if (!AutoscalerServiceClient.getServiceClient().checkServiceLBExistenceAgainstPolicy(type,
-// deploymentPolicyName)) {
-//
-// lbCartridgeInfo.addProperties(property);
-// lbCartridgeInfo.addProperties(loadBalancedServiceTypeProperty);
-//
-// lbService = new LBService(lbCartridgeType,
-// lbCartridgeInfo.getDefaultAutoscalingPolicy(),
-// deploymentPolicyName, tenantId,
-// lbCartridgeInfo,
-// tenantRange);
-//
-// Properties lbDeploymentProperties = new Properties();
-//
-// // check if there are properties in LB cartridge info
-// Property [] cartridgeInfoProps = lbCartridgeInfo.getProperties();
-// if (cartridgeInfoProps != null && cartridgeInfoProps.length > 0) {
-// lbDeploymentProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{property, loadBalancedServiceTypeProperty}));
-// } else {
-// lbDeploymentProperties.setProperties(new Property[]{property, loadBalancedServiceTypeProperty});
-// }
-//
-// lbService.deploy(lbDeploymentProperties);
-//
-// // persist
-// persist(lbService);
-// }
-// }
-// }
-//
-// } catch (Exception ex) {
-// // we don't need to throw the error here.
-// log.error(ex.getMessage(), ex);
-// }
-//
-//
-// lbRefProp.add(property);
-// break;
-// }
-// }
-// }
-// }
-
- LBDataContext lbDataCtxt = null;
-
- // get lb config reference
- LoadbalancerConfig lbConfig = cartridgeInfo.getLbConfig();
- if (lbConfig == null || lbConfig.getProperties() == null) {
- // no LB ref
- if (log.isDebugEnabled()) {
- log.debug("This Service does not require a load balancer. " + "[Service Name] " + type);
- }
-
- } else {
- // LB ref found, get relevant LB Context data
- lbDataCtxt = CartridgeSubscriptionUtils.getLoadBalancerDataContext(-1234, type, deploymentPolicyName, lbConfig);
-
- // deploy LB service cluster
- deployLBCluster(type, lbDataCtxt, tenantRange);
- }
-
- Service service = new MultiTenantService(type, autoscalingPolicyName, deploymentPolicyName, tenantId, cartridgeInfo, tenantRange, isPublic);
-
- Properties serviceClusterProperties = null;
- if (lbDataCtxt != null) {
- if (lbDataCtxt.getLoadBalancedServiceProperties() != null && !lbDataCtxt.getLoadBalancedServiceProperties().isEmpty()) {
- serviceClusterProperties = new Properties();
- serviceClusterProperties.setProperties(lbDataCtxt.getLoadBalancedServiceProperties().toArray(new Property[0]));
- }
- }
-
- // create
- service.create();
-
- //deploy the service
- service.deploy(serviceClusterProperties);
-
- // persist
- persist(service);
-
- return service;
- }
-
- private void deployLBCluster (String loadBalancedService, LBDataContext lbDataCtxt, String tenantRange) throws ADCException, UnregisteredCartridgeException {
-
- if (lbDataCtxt.getLbCategory() == null || lbDataCtxt.getLbCategory().equals(StratosConstants.NO_LOAD_BALANCER)) {
- // no load balancer required
- return;
- }
-
- LBService lbService = null;
-
- if (lbDataCtxt.getLbCategory().equals(StratosConstants.EXISTING_LOAD_BALANCERS)) {
- lbService = new ExistingLBService(lbDataCtxt.getLbCartridgeInfo().getType(), lbDataCtxt.getAutoscalePolicy(),
- lbDataCtxt.getDeploymentPolicy(), -1234, lbDataCtxt.getLbCartridgeInfo(),
- tenantRange, false);
-
- } else if (lbDataCtxt.getLbCategory().equals(StratosConstants.DEFAULT_LOAD_BALANCER)) {
- lbService = new DefaultLBService(lbDataCtxt.getLbCartridgeInfo().getType(), lbDataCtxt.getAutoscalePolicy(),
- lbDataCtxt.getDeploymentPolicy(), -1234, lbDataCtxt.getLbCartridgeInfo(),
- tenantRange, false);
-
- } else if (lbDataCtxt.getLbCategory().equals(StratosConstants.SERVICE_AWARE_LOAD_BALANCER)) {
- lbService = new ServiceAwareLBService(lbDataCtxt.getLbCartridgeInfo().getType(), lbDataCtxt.getAutoscalePolicy(),
- lbDataCtxt.getDeploymentPolicy(), -1234, lbDataCtxt.getLbCartridgeInfo(),
- tenantRange, false);
- }
-
- if (lbService == null) {
- throw new ADCException("The given Load Balancer category " + lbDataCtxt.getLbCategory() + " not found");
- }
-
- // Set the load balanced service type
- lbService.setLoadBalancedServiceType(loadBalancedService);
-
- // Set if the load balanced service is multi tenant or not
- //lbService.setLoadBalancedServiceMultiTenant(true); // TODO --- temp hack
-
- // set the relevant deployment policy
- //log.info(" ******* Setting Deployment Policy name : ------> " + lbDataCtxt.getDeploymentPolicy());
- //loadBalancerCategory.setDeploymentPolicyName(lbDataCtxt.getDeploymentPolicy());
-
- Properties lbProperties = null;
- if (lbDataCtxt.getLbProperperties() != null && !lbDataCtxt.getLbProperperties().isEmpty()) {
- lbProperties = new Properties();
- lbProperties.setProperties(lbDataCtxt.getLbProperperties().toArray(new Property[0]));
- }
-
- // create service
- lbService.create();
-
- // add LB category to the payload
- if (lbService.getPayloadData() != null) {
- lbService.getPayloadData().add(CartridgeConstants.LB_CATEGORY, lbDataCtxt.getLbCategory());
- }
-
- // delpoy
- lbService.deploy(lbProperties);
-
- // persist
- persist(lbService);
- }
-
- private void persist (Service service) throws ADCException {
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-
- try {
- dataInsertionAndRetrievalManager.persistService(service);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in persisting Service in PersistenceManager";
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
- }
-
- public Service getService (String type) throws ADCException {
-
- try {
- return new DataInsertionAndRetrievalManager().getService(type);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in getting Service for type " + type;
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
- }
-
- public Collection<Service> getServices () throws ADCException {
-
- try {
- return new DataInsertionAndRetrievalManager().getServices();
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in getting deployed Services";
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
- }
-
- public void undeployService (String type) throws ADCException, ServiceDoesNotExistException {
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-
- // check if there are already created Subscriptions for this type
- Collection<CartridgeSubscription> cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(type);
- if (cartridgeSubscriptions != null) {
- if (!cartridgeSubscriptions.isEmpty()) {
- // can't undeploy; there are existing Subscriptions
- String errorMsg = "Cannot undeploy Service since existing Subscriptions are found";
- log.error(errorMsg);
- throw new ServiceDoesNotExistException(errorMsg, type);
- }
- }
-
- if (log.isDebugEnabled()) {
- log.debug("No subscriptions found for service type: " + type + " , proceeding with undeploying service");
- }
-
- Service service;
- try {
- service = dataInsertionAndRetrievalManager.getService(type);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in checking if Service is available is PersistenceManager";
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
-
- if (service == null) {
- String errorMsg = "No service found for type " + type;
- log.error(errorMsg);
- throw new ADCException(errorMsg);
- }
-
- // if service is found, undeploy
- try {
- service.undeploy();
-
- } catch (NotSubscribedException e) {
- String errorMsg = "Undeploying Service Cluster failed for " + type;
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
-
- try {
- dataInsertionAndRetrievalManager.removeService(type);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in removing Service from PersistenceManager";
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
- }
-
- @SuppressWarnings("unused")
- private static Property[] combine (Property[] propertyArray1, Property[] propertyArray2) {
-
- int length = propertyArray1.length + propertyArray2.length;
- Property[] combinedProperties = new Property[length];
- System.arraycopy(propertyArray1, 0, combinedProperties, 0, propertyArray1.length);
- System.arraycopy(propertyArray2, 0, combinedProperties, propertyArray1.length, propertyArray2.length);
-
- return combinedProperties;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/MultiTenantService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/MultiTenantService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/MultiTenantService.java
deleted file mode 100644
index 6111f8d..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/MultiTenantService.java
+++ /dev/null
@@ -1,33 +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.manager.deploy.service.multitenant;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.manager.deploy.service.Service;
-
-public class MultiTenantService extends Service {
-
- private static final long serialVersionUID = 3038272784193474660L;
-
- public MultiTenantService (String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId, CartridgeInfo cartridgeInfo,
- String tenantRange, boolean isPublic) {
- super(type, autoscalingPolicyName, deploymentPolicyName, tenantId, cartridgeInfo, tenantRange, isPublic);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java
deleted file mode 100644
index 66175e3..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/DefaultLBService.java
+++ /dev/null
@@ -1,111 +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.manager.deploy.service.multitenant.lb;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.ClusterContext;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.client.AutoscalerServiceClient;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-
-import java.rmi.RemoteException;
-import java.util.Map;
-
-public class DefaultLBService extends LBService {
-
- private static final long serialVersionUID = 8650714821857129052L;
- private static Log log = LogFactory.getLog(DefaultLBService.class);
- private boolean defaultLBServiceExists = false;
-
- public DefaultLBService (String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId,
- CartridgeInfo cartridgeInfo, String tenantRange, boolean isPublic) {
-
- super(type, autoscalingPolicyName, deploymentPolicyName, tenantId, cartridgeInfo, tenantRange, isPublic);
- }
-
- public PayloadData create(String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries)
- throws ADCException, AlreadySubscribedException {
-
- // call the relevant method to get the cluster id, using deployment policy
- String clusterId = null;
-// try {
-// clusterId = AutoscalerServiceClient.getServiceClient().getDefaultLBClusterId(getDeploymentPolicyName());
-// } catch (Exception e) {
-// log.error("Error occurred in retrieving default LB cluster id" + e.getMessage());
-// throw new ADCException(e);
-// }
-
- if (clusterId != null) {
- //set the cluster id to Cluster object
- cluster.setClusterDomain(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("Set existing default LB cluster id " + clusterId);
- }
- defaultLBServiceExists = true;
-
- //get the hostname for this cluster and set it
- ClusterContext clusterContext;
- try {
- clusterContext = CloudControllerServiceClient.getServiceClient().getClusterContext(clusterId);
-
- } catch (RemoteException e) {
- log.error("Error occurred in retrieving Cluster Context for default LB ", e);
- throw new ADCException(e);
- }
-
- if (clusterContext != null) {
- cluster.setHostName(clusterContext.getHostName());
- if (log.isDebugEnabled()) {
- log.debug("Set existing default LB hostname " + clusterContext.getHostName());
- }
- }
-
- return null;
-
- } else {
- // set cluster domain
- cluster.setClusterDomain(generateClusterId(null, cartridgeInfo.getType()));
- // set hostname
- cluster.setHostName(generateHostName(null, cartridgeInfo.getHostName()));
-
- return createPayload(cartridgeInfo, subscriptionKey, subscriber, cluster, repository, alias, customPayloadEntries);
- }
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException {
-
- //log.info("Register service with payload data ["+payloadData+"] ");
- if (!defaultLBServiceExists) {
- super.register(cartridgeInfo, cluster, payloadData, autoscalePolicyName, deploymentPolicyName, properties, null);
- }else {
- log.info("Default LB already exists for deployment policy: " + getDeploymentPolicyName());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ExistingLBService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ExistingLBService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ExistingLBService.java
deleted file mode 100644
index 7d935be..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ExistingLBService.java
+++ /dev/null
@@ -1,54 +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.manager.deploy.service.multitenant.lb;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-
-import java.util.Map;
-
-public class ExistingLBService extends LBService {
-
- private static final long serialVersionUID = -421015139303889832L;
-
- public ExistingLBService(String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId, CartridgeInfo cartridgeInfo, String tenantRange, boolean isPublic) {
- super(type, autoscalingPolicyName, deploymentPolicyName, tenantId, cartridgeInfo, tenantRange, isPublic);
- }
-
- public PayloadData create(String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries)
- throws ADCException, AlreadySubscribedException {
-
- // TODO
- return null;
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException {
-
- // TODO
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/LBService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/LBService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/LBService.java
deleted file mode 100644
index 2ca815e..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/LBService.java
+++ /dev/null
@@ -1,66 +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.manager.deploy.service.multitenant.lb;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-
-public class LBService extends Service {
-
- private static final long serialVersionUID = 7202575406524382777L;
-
- private String loadBalancedServiceType;
-
- public LBService(String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId,
- CartridgeInfo cartridgeInfo, String tenantRange, boolean isPublic) {
-
- super(type, autoscalingPolicyName, deploymentPolicyName, tenantId, cartridgeInfo, tenantRange, isPublic);
- }
-
- public void create () throws ADCException {
-
- try {
- setPayloadData(create(null, getCluster(), null, null, getCartridgeInfo(), getSubscriptionKey(), null));
-
- } catch (AlreadySubscribedException e) {
- throw new ADCException(e);
- }
- }
-
- @Override
- public void deploy(Properties properties) throws ADCException, UnregisteredCartridgeException {
-
- //register the service
- register(getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), getDeploymentPolicyName(),
- properties, null);
- }
-
- public String getLoadBalancedServiceType() {
- return loadBalancedServiceType;
- }
-
- public void setLoadBalancedServiceType(String loadBalancedServiceType) {
- this.loadBalancedServiceType = loadBalancedServiceType;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/MultiTenantLBService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/MultiTenantLBService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/MultiTenantLBService.java
deleted file mode 100644
index 228bea1..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/MultiTenantLBService.java
+++ /dev/null
@@ -1,49 +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.manager.deploy.service.multitenant.lb;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.lb.category.LoadBalancerCategory;
-
-public class MultiTenantLBService extends Service {
-
- private static final long serialVersionUID = 2930474060830972961L;
-
- private LoadBalancerCategory loadBalancerCategory;
-
- public MultiTenantLBService(String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId,
- CartridgeInfo cartridgeInfo, String tenantRange, boolean isPublic, LoadBalancerCategory loadBalancerCategory) {
-
- super(type, autoscalingPolicyName, deploymentPolicyName, tenantId, cartridgeInfo, tenantRange, isPublic);
- this.loadBalancerCategory = loadBalancerCategory;
- }
-
- @Override
- public void deploy(Properties properties) throws ADCException, UnregisteredCartridgeException {
-
- //register the service
- loadBalancerCategory.register(getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), getDeploymentPolicyName(),
- properties, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java
deleted file mode 100644
index 96111bf..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/deploy/service/multitenant/lb/ServiceAwareLBService.java
+++ /dev/null
@@ -1,139 +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.manager.deploy.service.multitenant.lb;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.ClusterContext;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.client.AutoscalerServiceClient;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-import java.rmi.RemoteException;
-import java.util.Map;
-
-public class ServiceAwareLBService extends LBService {
-
- private static final long serialVersionUID = -4107281204555031986L;
-
- public ServiceAwareLBService(String type, String autoscalingPolicyName, String deploymentPolicyName, int tenantId,
- CartridgeInfo cartridgeInfo, String tenantRange, boolean isPublic) {
-
- super(type, autoscalingPolicyName, deploymentPolicyName, tenantId, cartridgeInfo, tenantRange, isPublic);
- }
-
- private static Log log = LogFactory.getLog(ServiceAwareLBService.class);
-
- private boolean serviceAwareLBExists;
-
- public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries) throws ADCException, AlreadySubscribedException {
-
- // call the relevant method to get the cluster id, using deployment policy and type
- String clusterId = null;
-
-// try {
-// clusterId = AutoscalerServiceClient.getServiceClient().getServiceLBClusterId(getLoadBalancedServiceType(), getDeploymentPolicyName());
-//
-// } catch (Exception e) {
-// log.error("Error occurred in retrieving Service LB cluster id" + e.getMessage());
-// throw new ADCException(e);
-// }
-
- if (clusterId != null) {
-
- //set the cluster id to Cluster object
- cluster.setClusterDomain(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("Set existing Service LB cluster id " + clusterId);
- }
- serviceAwareLBExists = true;
-
- //get the hostname for this cluster and set it
- ClusterContext clusterContext;
- try {
- clusterContext = CloudControllerServiceClient.getServiceClient().getClusterContext(clusterId);
-
- } catch (RemoteException e) {
- log.error("Error occurred in retrieving Cluster Context for Service LB ", e);
- throw new ADCException(e);
- }
-
- if (clusterContext != null) {
- cluster.setHostName(clusterContext.getHostName());
- if (log.isDebugEnabled()) {
- log.debug("Set existing Service LB hostname " + clusterContext.getHostName());
- }
- }
-
- return null;
-
- } else {
-
- // set cluster domain
- cluster.setClusterDomain(generateClusterId(getLoadBalancedServiceType(), cartridgeInfo.getType()));
- // set hostname
- cluster.setHostName(generateHostName(getLoadBalancedServiceType(), cartridgeInfo.getHostName()));
-
- PayloadData serviceLevelLbPayloadData = createPayload(cartridgeInfo, subscriptionKey, subscriber, cluster,
- repository, alias, customPayloadEntries);
-
- // add payload entry for load balanced service type
- serviceLevelLbPayloadData.add(CartridgeConstants.LOAD_BALANCED_SERVICE_TYPE, getLoadBalancedServiceType());
- return serviceLevelLbPayloadData;
- }
- }
-
- protected String generateClusterId (String loadBalancedServiceType, String cartridgeType) {
-
- String clusterId = cartridgeType + "." + loadBalancedServiceType + "." + getCartridgeInfo().getHostName() + ".domain";
- // limit the cartridge alias to 30 characters in length
- if (clusterId.length() > 30) {
- clusterId = CartridgeSubscriptionUtils.limitLengthOfString(clusterId, 30);
- }
-
- return clusterId;
- }
-
- protected String generateHostName (String loadBalancedServiceType, String cartridgeDefinitionHostName) {
-
- return getCartridgeInfo().getType() + "." + loadBalancedServiceType + "." + cartridgeDefinitionHostName;
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException {
-
- if (!serviceAwareLBExists) {
- super.register(cartridgeInfo, cluster, payloadData, autoscalePolicyName, deploymentPolicyName, properties, null);
-
- }else {
- log.info("Service Aware LB already exists for cartridge type: " + getLoadBalancedServiceType() + ", deployment policy: " + getDeploymentPolicyName());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationDefinition.java
new file mode 100644
index 0000000..43b6e8f
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationDefinition.java
@@ -0,0 +1,95 @@
+/*
+ * 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.manager.domain;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class ApplicationDefinition implements Serializable {
+
+ private static final long serialVersionUID = -2829206180707597651L;
+
+ private String applicationId;
+ private String name;
+ private String description;
+ private String alias;
+ private ComponentDefinition components;
+ private String status;
+ private List<PropertyBean> property;
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public ComponentDefinition getComponents() {
+ return components;
+ }
+
+ public void setComponents(ComponentDefinition components) {
+ this.components = components;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public List<PropertyBean> getProperty() {
+ return property;
+ }
+
+ public void setProperty(List<PropertyBean> property) {
+ this.property = property;
+ }
+}
[06/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java
deleted file mode 100644
index 1cd8ad9..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/RepositoryNotification.java
+++ /dev/null
@@ -1,80 +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.manager.repository;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.publisher.InstanceNotificationPublisher;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.util.Set;
-
-public class RepositoryNotification {
-
- private static final Log log = LogFactory.getLog(RepositoryNotification.class);
-
- public void updateRepository(String url) {
-
- if ( StringUtils.isNotBlank(url)) {
-
- Set<CartridgeSubscription> cartridgeSubscriptions = new DataInsertionAndRetrievalManager().
- getCartridgeSubscriptionForRepository(url);
-
- if (cartridgeSubscriptions == null || cartridgeSubscriptions.isEmpty()) {
- // No subscriptions, return
- if (log.isDebugEnabled()) {
- log.debug("No subscription information found for repo url : " + url);
- }
-
- return;
- }
-
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- updateRepository(cartridgeSubscription);
- }
- }
- }
-
- public void updateRepository(CartridgeSubscription cartridgeSubscription) {
- Repository repository = cartridgeSubscription.getRepository();
- if (repository != null) {
- InstanceNotificationPublisher publisher = new InstanceNotificationPublisher();
- publisher.publishArtifactUpdatedEvent(
- String.valueOf(cartridgeSubscription.getCluster().getClusterDomain()),
- String.valueOf(cartridgeSubscription.getSubscriber().getTenantId()),
- repository.getUrl(),
- repository.getUserName(),
- repository.getPassword(),
- repository.isCommitEnabled());
-
- if (log.isInfoEnabled()) {
- log.info(String.format("Artifact updated event published: %s [cartridge-type] %s " +
- "%s [subscription-alias] %s [repo-url] %s",
- cartridgeSubscription.getType(), cartridgeSubscription.getAlias(), repository.getUrl()));
- }
- } else {
- if (log.isWarnEnabled()) {
- log.warn("No repository found for subscription with alias: " + cartridgeSubscription.getAlias()
- + ", type: " + cartridgeSubscription.getType() + ". Not sending artifact updated event");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java
deleted file mode 100644
index a386c03..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/retriever/DataInsertionAndRetrievalManager.java
+++ /dev/null
@@ -1,411 +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.manager.retriever;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.lookup.LookupDataHolder;
-import org.apache.stratos.manager.persistence.PersistenceManager;
-import org.apache.stratos.manager.persistence.RegistryBasedPersistenceManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.ApplicationSubscription;
-import org.apache.stratos.manager.subscription.GroupSubscription;
-
-import java.util.Collection;
-import java.util.Set;
-
-public class DataInsertionAndRetrievalManager {
-
- private static final Log log = LogFactory.getLog(DataInsertionAndRetrievalManager.class);
-
- // TODO: use a global object
- private static PersistenceManager persistenceManager = new RegistryBasedPersistenceManager();
-
- public void cacheAndPersistSubcription (CartridgeSubscription cartridgeSubscription) throws PersistenceManagerException {
-
- // get the write lock
- LookupDataHolder.getInstance().acquireWriteLock();
-
- try {
- // store in LookupDataHolder
- LookupDataHolder.getInstance().putSubscription(cartridgeSubscription);
-
- try {
- // store in Persistence Manager
- persistenceManager.persistCartridgeSubscription(cartridgeSubscription);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in persisting CartridgeSubscription in Persistence Manager";
- log.error(errorMsg, e);
- // remove from the in memory model since persisting failed
- LookupDataHolder.getInstance().removeSubscription(cartridgeSubscription.getSubscriber().getTenantId(), cartridgeSubscription.getType(),
- cartridgeSubscription.getAlias(), cartridgeSubscription.getClusterDomain(),
- cartridgeSubscription.getRepository() != null ? cartridgeSubscription.getRepository().getUrl() : null);
-
- throw e;
- }
-
- } finally {
- // release the write lock
- LookupDataHolder.getInstance().releaseWriteLock();
- }
- }
-
- public void cacheAndUpdateSubscription(CartridgeSubscription cartridgeSubscription) throws PersistenceManagerException {
-
- // get the write lock
- LookupDataHolder.getInstance().acquireWriteLock();
-
- try {
- // store in LookupDataHolder
- LookupDataHolder.getInstance().putSubscription(cartridgeSubscription);
-
- try {
- // store in Persistence Manager
- persistenceManager.persistCartridgeSubscription(cartridgeSubscription);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in updating cartridge subscription in persistence manager";
- log.error(errorMsg, e);
- throw e;
- }
-
- } finally {
- // release the write lock
- LookupDataHolder.getInstance().releaseWriteLock();
- }
- }
-
- public void removeSubscription (int tenantId, String subscriptionAlias) throws PersistenceManagerException {
-
- CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(tenantId, subscriptionAlias);
-
- if (cartridgeSubscription == null) {
- if (log.isDebugEnabled()) {
- log.debug("No CartridgeSubscription found for tenant " + tenantId + ", subscription alias " + subscriptionAlias);
- }
- return;
- }
-
- String cartridgeType = cartridgeSubscription.getType();
- String clusterId = cartridgeSubscription.getClusterDomain();
-
- LookupDataHolder.getInstance().acquireWriteLock();
-
- try {
- // remove from persistence manager
- try {
- persistenceManager.removeCartridgeSubscription(tenantId, cartridgeType, subscriptionAlias);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in removing CartridgeSubscription from Persistence Manager";
- log.error(errorMsg, e);
- throw e;
- }
-
- // remove from cache
- LookupDataHolder.getInstance().removeSubscription(tenantId, cartridgeType, subscriptionAlias, clusterId,
- cartridgeSubscription.getRepository() != null ? cartridgeSubscription.getRepository().getUrl() : null);
-
- } finally {
- LookupDataHolder.getInstance().releaseWriteLock();
- }
- }
-
- public void cachePersistedSubscriptions () throws PersistenceManagerException {
-
- Collection<CartridgeSubscription> cartridgeSubscriptions;
-
- // get the write lock
- LookupDataHolder.getInstance().acquireWriteLock();
-
- try {
- try {
- cartridgeSubscriptions = persistenceManager.getCartridgeSubscriptions();
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in retrieving CartridgeSubscriptions from Persistence Manager";
- log.error(errorMsg, e);
- throw e;
- }
-
- if(cartridgeSubscriptions == null || cartridgeSubscriptions.isEmpty()) {
- if(log.isDebugEnabled()) {
- log.debug("No CartridgeSubscriptions found to add to the cache");
- }
- return;
- }
- cacheSubscriptions(cartridgeSubscriptions);
-
- } finally {
- // release the write lock
- LookupDataHolder.getInstance().releaseWriteLock();
- }
- }
-
- public void cachePersistedSubscriptions (int tenantId) throws PersistenceManagerException {
-
- Collection<CartridgeSubscription> cartridgeSubscriptions;
-
- // get the write lock
- LookupDataHolder.getInstance().acquireWriteLock();
-
- try {
- try {
- cartridgeSubscriptions = persistenceManager.getCartridgeSubscriptions(tenantId);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in retrieving CartridgeSubscriptions from Persistence Manager";
- log.error(errorMsg, e);
- throw e;
- }
-
- if(cartridgeSubscriptions == null || cartridgeSubscriptions.isEmpty()) {
- if(log.isDebugEnabled()) {
- log.debug("No CartridgeSubscriptions found to add to the cache");
- }
- return;
- }
- cacheSubscriptions(cartridgeSubscriptions);
-
- } finally {
- // release the write lock
- LookupDataHolder.getInstance().releaseWriteLock();
- }
- }
-
- public void cacheSubscriptionsWithoutPersisting (Collection<CartridgeSubscription> cartridgeSubscriptions) {
-
- // get the write lock
- LookupDataHolder.getInstance().acquireWriteLock();
-
- try {
- cacheSubscriptions(cartridgeSubscriptions);
-
- } finally {
- // release the write lock
- LookupDataHolder.getInstance().releaseWriteLock();
- }
- }
-
- public void removeSubscriptionFromCache (int tenantId, String subscriptionAlias) {
-
- LookupDataHolder.getInstance().acquireWriteLock();
-
- CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(tenantId, subscriptionAlias);
- if (cartridgeSubscription == null) {
- if (log.isDebugEnabled()) {
- log.debug("No CartridgeSubscription found for tenant " + tenantId + ", subscription alias " + subscriptionAlias);
- }
- return;
- }
-
- String cartridgeType = cartridgeSubscription.getType();
- String clusterId = cartridgeSubscription.getClusterDomain();
-
- try {
- // remove from cache
- LookupDataHolder.getInstance().removeSubscription(tenantId, cartridgeType, subscriptionAlias, clusterId,
- cartridgeSubscription.getRepository() != null ? cartridgeSubscription.getRepository().getUrl() : null);
-
- } finally {
- LookupDataHolder.getInstance().releaseWriteLock();
- }
- }
-
- private void cacheSubscriptions (Collection<CartridgeSubscription> cartridgeSubscriptions) {
-
- // cache all
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- LookupDataHolder.getInstance().putSubscription(cartridgeSubscription);
- if (log.isDebugEnabled()) {
- log.debug("Updated the in memory cache with the CartridgeSubscription: " + cartridgeSubscription.toString());
- }
- }
- }
-
- public void persistService (Service service) throws PersistenceManagerException {
-
- persistenceManager.persistService(service);
- }
-
- public Collection<Service> getServices() throws PersistenceManagerException {
-
- return persistenceManager.getServices();
- }
-
- public Service getService (String cartridgeType) throws PersistenceManagerException {
-
- return persistenceManager.getService(cartridgeType);
- }
-
- public void removeService (String cartridgeType) throws PersistenceManagerException {
-
- persistenceManager.removeService(cartridgeType);
- }
-
- public Collection<CartridgeSubscription> getCartridgeSubscriptions(String cartridgeType) {
-
- // acquire read lock
- LookupDataHolder.getInstance().acquireReadLock();
-
- try {
- return LookupDataHolder.getInstance().getSubscriptions(cartridgeType);
-
- } finally {
- // release read lock
- LookupDataHolder.getInstance().releaseReadLock();
- }
- }
-
- public CartridgeSubscription getCartridgeSubscription (int tenantId, String subscriptionAlias) {
-
- // acquire read lock
- LookupDataHolder.getInstance().acquireReadLock();
-
- try {
- return LookupDataHolder.getInstance().getSubscriptionForAlias(tenantId, subscriptionAlias);
-
- } finally {
- // release read lock
- LookupDataHolder.getInstance().releaseReadLock();
- }
- }
-
- public Set<CartridgeSubscription> getCartridgeSubscriptionForCluster (String clusterId) {
-
- // acquire read lock
- LookupDataHolder.getInstance().acquireReadLock();
-
- try {
- return LookupDataHolder.getInstance().getSubscription(clusterId);
-
- } finally {
- // release read lock
- LookupDataHolder.getInstance().releaseReadLock();
- }
- }
-
- public Set<CartridgeSubscription> getCartridgeSubscriptionForRepository (String repoUrl) {
-
- // acquire read lock
- LookupDataHolder.getInstance().acquireReadLock();
-
- try {
- return LookupDataHolder.getInstance().getSubscriptionsForRepoUrl(repoUrl);
-
- } finally {
- // release read lock
- LookupDataHolder.getInstance().releaseReadLock();
- }
- }
-
- public Collection<CartridgeSubscription> getCartridgeSubscriptions (int tenantId) {
-
- // acquire read lock
- LookupDataHolder.getInstance().acquireReadLock();
-
- try {
- return LookupDataHolder.getInstance().getSubscriptions(tenantId);
-
- } finally {
- // release read lock
- LookupDataHolder.getInstance().releaseReadLock();
- }
- }
-
- public Collection<CartridgeSubscription> getCartridgeSubscriptions (int tenantId, String cartridgeType) {
-
- // acquire read lock
- LookupDataHolder.getInstance().acquireReadLock();
-
- try {
- return LookupDataHolder.getInstance().getSubscriptionForType(tenantId, cartridgeType);
-
- } finally {
- // release read lock
- LookupDataHolder.getInstance().releaseReadLock();
- }
- }
-
- //Don't use this method unless absolutely necessary, use getCartridgeSubscription (int tenantId, String subscriptionAlias)
- public CartridgeSubscription getCartridgeSubscriptionForAlias (String subscriptionAlias) {
-
- // acquire read lock
- LookupDataHolder.getInstance().acquireReadLock();
-
- try {
- return LookupDataHolder.getInstance().getSubscriptionForAlias(subscriptionAlias);
-
- } finally {
- // release read lock
- LookupDataHolder.getInstance().releaseReadLock();
- }
- }
-
- public void peristServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException {
-
- persistenceManager.persistServiceGroupDefinition(serviceGroupDefinition);
- }
-
- public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException {
-
- return persistenceManager.getServiceGroupDefinition(serviceGroupDefinitionName);
- }
-
- public void removeServiceGroupDefinition (String serviceGroupName) throws PersistenceManagerException {
-
- persistenceManager.removeServiceGroupDefinition(serviceGroupName);
- }
-
- public void persistGroupSubscription (GroupSubscription groupSubscription) throws PersistenceManagerException {
-
- persistenceManager.persistGroupSubscription(groupSubscription);
- }
-
- public GroupSubscription getGroupSubscription (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException {
-
- return persistenceManager.getGroupSubscription(tenantId, groupName, groupAlias);
- }
-
- public void removeGroupSubscription (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException {
-
- persistenceManager.removeGroupSubscription(tenantId, groupName, groupAlias);
- }
-
- public void persistApplicationSubscription (ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException {
-
- persistenceManager.persistCompositeAppSubscription(compositeAppSubscription);
- }
-
- public ApplicationSubscription getApplicationSubscription (int tenantId, String appId) throws PersistenceManagerException {
-
- return persistenceManager.getCompositeAppSubscription(tenantId, appId);
- }
-
- public void removeApplicationSubscription (int tenantId, String appId) throws PersistenceManagerException {
-
- persistenceManager.removeCompositeAppSubscription(tenantId, appId);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/InstanceCleanupNotificationService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/InstanceCleanupNotificationService.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/InstanceCleanupNotificationService.java
deleted file mode 100644
index d8e6e4d..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/InstanceCleanupNotificationService.java
+++ /dev/null
@@ -1,42 +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.manager.service;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.publisher.InstanceNotificationPublisher;
-import org.wso2.carbon.core.AbstractAdmin;
-
-/**
- * This service will get invoked by Autoscaler when it trying to scale down an instance
- * in order for the instance to perform clean up task before the actual termination.
- */
-public class InstanceCleanupNotificationService extends AbstractAdmin {
- private static final Log log = LogFactory.getLog(InstanceCleanupNotificationService.class);
-
- public void sendInstanceCleanupNotificationForMember(String memberId) {
- //sending the notification event to the instance
- new InstanceNotificationPublisher().sendInstanceCleanupEventForMember(memberId);
- }
-
- public void sendInstanceCleanupNotificationForCluster(String clusterId) {
- //sending the notification event to the cluster
- new InstanceNotificationPublisher().sendInstanceCleanupEventForCluster(clusterId);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/RepositoryInfoBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/RepositoryInfoBean.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/RepositoryInfoBean.java
deleted file mode 100644
index c9a6ac0..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/service/RepositoryInfoBean.java
+++ /dev/null
@@ -1,85 +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.manager.service;
-
-import java.util.Arrays;
-
-/**
- *
- */
-public class RepositoryInfoBean {
-
- private String repoURL;
- private String cartridgeAlias;
- private String tenantDomain;
- private String userName;
- private String password;
- private String[] dirArray;
-
- public RepositoryInfoBean(String repoURL, String cartridgeAlias, String tenantDomain,
- String userName, String password, String[] dirArray) {
- this.repoURL = repoURL;
- this.cartridgeAlias = cartridgeAlias;
- this.tenantDomain = tenantDomain;
- this.userName = userName;
- this.setPassword(password);
- setDirArray(dirArray);
- }
- public String getRepoURL() {
- return repoURL;
- }
- public void setRepoURL(String repoURL) {
- this.repoURL = repoURL;
- }
- public String getCartridgeAlias() {
- return cartridgeAlias;
- }
- public void setCartridgeAlias(String cartridgeAlias) {
- this.cartridgeAlias = cartridgeAlias;
- }
- public String getTenantDomain() {
- return tenantDomain;
- }
- public void setTenantDomain(String tenantDomain) {
- this.tenantDomain = tenantDomain;
- }
- public String getUserName() {
- return userName;
- }
- public void setUserName(String userName) {
- this.userName = userName;
- }
- public String[] getDirArray() {
- return dirArray;
- }
- public void setDirArray(String[] dirArray) {
- if(dirArray == null) {
- this.dirArray = new String[0];
- } else {
- this.dirArray = Arrays.copyOf(dirArray, dirArray.length);
- }
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/statistics/publisher/CartridgeSubscriptionDataPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/statistics/publisher/CartridgeSubscriptionDataPublisher.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/statistics/publisher/CartridgeSubscriptionDataPublisher.java
new file mode 100644
index 0000000..6cbff31
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/statistics/publisher/CartridgeSubscriptionDataPublisher.java
@@ -0,0 +1,176 @@
+/*
+ * 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.manager.statistics.publisher;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.manager.exception.ADCException;
+import org.apache.stratos.manager.utils.CartridgeConstants;
+import org.wso2.carbon.base.ServerConfiguration;
+import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
+import org.wso2.carbon.databridge.agent.thrift.exception.AgentException;
+import org.wso2.carbon.databridge.commons.Attribute;
+import org.wso2.carbon.databridge.commons.AttributeType;
+import org.wso2.carbon.databridge.commons.Event;
+import org.wso2.carbon.databridge.commons.StreamDefinition;
+import org.wso2.carbon.utils.CarbonUtils;
+
+/**
+ * This will publish the subscription details of tenants to a data receiver.
+ * Data is published when a tenant subscribe to a cartridge and when it unsubscribe.
+ */
+public class CartridgeSubscriptionDataPublisher {
+
+ private static final Log log = LogFactory
+ .getLog(CartridgeSubscriptionDataPublisher.class);
+ private static AsyncDataPublisher dataPublisher;
+ private static StreamDefinition streamDefinition;
+ private static final String stratosManagerEventStreamVersion = "1.0.0";
+
+ @SuppressWarnings("deprecation")
+ public static void publish(int tenantID, String adminUser,
+ String cartridgeAlias, String cartridgeType, String repositoryUrl,
+ boolean isMultiTenant, String autoScalingPolicy,
+ String deploymentPolicy, String clusterID, String hostName,
+ String mappedDomain, String action) throws ADCException {
+
+ //check if bam is enabled in cartridge-config.properties
+ if(! Boolean.parseBoolean(System.getProperty(CartridgeConstants.BAM_PUBLISHER_ENABLED))){
+ return;
+ }
+
+ log.debug(CartridgeConstants.DATA_PUB_TASK_NAME+" cycle started.");
+
+ if (dataPublisher == null) {
+ createDataPublisher();
+
+ // If we cannot create a data publisher we should give up
+ // this means data will not be published
+ if (dataPublisher == null) {
+ log.error("Data Publisher cannot be created or found.");
+ return;
+ }
+ }
+
+ //Construct the data to be published
+ List<Object> payload = new ArrayList<Object>();
+
+ // Payload values
+ payload.add(String.valueOf(tenantID));
+ payload.add(handleNull(adminUser));
+ payload.add(handleNull(cartridgeAlias));
+ payload.add(cartridgeType);
+ payload.add(handleNull(repositoryUrl));
+ payload.add(handleNull(String.valueOf(isMultiTenant)));
+ payload.add(handleNull(autoScalingPolicy));
+ payload.add(handleNull(deploymentPolicy));
+ payload.add(String.valueOf(clusterID));
+ payload.add(handleNull(hostName));
+ payload.add(handleNull(mappedDomain));
+ payload.add(handleNull(action));
+
+ Event event = new Event();
+ event.setPayloadData(payload.toArray());
+ event.setArbitraryDataMap(new HashMap<String, String>());
+
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format(
+ "Publishing BAM event: [stream] %s [version] %s",
+ streamDefinition.getName(),
+ streamDefinition.getVersion()));
+ }
+ dataPublisher.publish(streamDefinition.getName(),
+ streamDefinition.getVersion(), event);
+ } catch (AgentException e) {
+ if (log.isErrorEnabled()) {
+ log.error(
+ String.format(
+ "Could not publish BAM event: [stream] %s [version] %s",
+ streamDefinition.getName(),
+ streamDefinition.getVersion()), e);
+ }
+ }
+ }
+
+ private static StreamDefinition initializeStream() throws Exception {
+ streamDefinition = new StreamDefinition( CartridgeConstants.STRATOS_MANAGER_EVENT_STREAM,
+ stratosManagerEventStreamVersion);
+ streamDefinition.setNickName("stratos.manager");
+ streamDefinition.setDescription("Tenant Subscription Data");
+ // Payload definition
+ List<Attribute> payloadData = new ArrayList<Attribute>();
+ payloadData.add(new Attribute(CartridgeConstants.TENANT_ID_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.ADMIN_USER_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.CARTRIDGE_ALIAS_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.CARTRIDGE_TYPE_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.REPOSITORY_URL_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.MULTI_TENANT_BEHAVIOR_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.AUTO_SCALE_POLICY_COL, AttributeType.STRING));
+ payloadData
+ .add(new Attribute(CartridgeConstants.DEPLOYMENT_POLICY_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.CLUSTER_ID_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.HOST_NAME_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.MAPPED_DOMAIN_COL, AttributeType.STRING));
+ payloadData.add(new Attribute(CartridgeConstants.ACTION_COL, AttributeType.STRING));
+ streamDefinition.setPayloadData(payloadData);
+ return streamDefinition;
+ }
+
+ private static void createDataPublisher() throws ADCException {
+ // creating the agent
+ ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
+ String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
+ String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
+
+ //value is in the carbon.xml file and should be set to the thrift port of BAM
+ String bamServerUrl = serverConfig.getFirstProperty("BamServerURL");
+
+ //getting the BAM related values from cartridge-config.properties
+ String adminUsername = System.getProperty(CartridgeConstants.BAM_ADMIN_USERNAME);
+ String adminPassword = System.getProperty(CartridgeConstants.BAM_ADMIN_PASSWORD);
+
+ System.setProperty("javax.net.ssl.trustStore", trustStorePath);
+ System.setProperty("javax.net.ssl.trustStorePassword",
+ trustStorePassword);
+
+ try {
+ dataPublisher = new AsyncDataPublisher(
+ "tcp://" + bamServerUrl + "", adminUsername, adminPassword);
+ initializeStream();
+ dataPublisher.addStreamDefinition(streamDefinition);
+ } catch (Exception e) {
+ String msg = "Unable to create a data publisher to "+ bamServerUrl;
+ log.error(msg, e);
+ throw new ADCException(msg, e);
+ }
+ }
+
+ private static String handleNull(String val) {
+ if (val == null) {
+ return "";
+ }
+ return val;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscriber/Subscriber.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscriber/Subscriber.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscriber/Subscriber.java
deleted file mode 100644
index cec252b..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscriber/Subscriber.java
+++ /dev/null
@@ -1,68 +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.manager.subscriber;
-
-import java.io.Serializable;
-
-public class Subscriber implements Serializable {
-
- private static final long serialVersionUID = 6429685206817913437L;
- private String adminUserName;
- private int tenantId;
- private String tenantDomain;
-
- public Subscriber (String adminUserName, int tenantId, String tenantDomain) {
-
- this.adminUserName = adminUserName;
- this.tenantId = tenantId;
- this.tenantDomain = tenantDomain;
- }
-
- public String getAdminUserName() {
- return adminUserName;
- }
-
- public void setAdminUserName(String adminUserName) {
- this.adminUserName = adminUserName;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getTenantDomain() {
- return tenantDomain;
- }
-
- public void setTenantDomain(String tenantDomain) {
- this.tenantDomain = tenantDomain;
- }
-
- @Override
- public String toString() {
- return "Subscriber [adminUserName=" + adminUserName + ", tenantId=" + tenantId +
- ", tenantDomain=" + tenantDomain + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationCartridgeSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationCartridgeSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationCartridgeSubscription.java
deleted file mode 100644
index 161f83f..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationCartridgeSubscription.java
+++ /dev/null
@@ -1,49 +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.manager.subscription;
-
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-
-public class ApplicationCartridgeSubscription extends CartridgeSubscription {
-
-
- private static final long serialVersionUID = 3969055979835359336L;
-
- /**
- * Constructor
- *
- * @param cartridgeInfo CartridgeInfo instance
- * @param subscriptionTenancyBehaviour SubscriptionTenancyBehaviour instance
- */
- public ApplicationCartridgeSubscription(CartridgeInfo cartridgeInfo, SubscriptionTenancyBehaviour
- subscriptionTenancyBehaviour) {
- super(cartridgeInfo, subscriptionTenancyBehaviour);
- }
-
-
- public Repository manageRepository (String repoURL, String repoUserName, String repoUserPassword,
- boolean privateRepo) {
-
- //no repository for application cartridge instances
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationSubscription.java
deleted file mode 100644
index ab5e005..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationSubscription.java
+++ /dev/null
@@ -1,78 +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.manager.subscription;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.jboss.util.propertyeditor.StringArrayEditor;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class ApplicationSubscription implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 3380699449827682550L;
-
- private static Log log = LogFactory.getLog(ApplicationSubscription.class);
-
- private String appId;
-
- private Set<String> cartridgeSubscriptionAliases;
-
- private Set<String> groupSubscriptionAliases;
-
- public ApplicationSubscription (String appId) {
-
- this.appId = appId;
- cartridgeSubscriptionAliases = new HashSet<String>();
- groupSubscriptionAliases = new HashSet<String>();
- }
-
- public Set<String> getGroupSubscriptionAliases() {
- return groupSubscriptionAliases;
- }
-
- public void addCartridgeSubscriptionAlias (String cartridgeSubscriptionAlias) {
- cartridgeSubscriptionAliases.add(cartridgeSubscriptionAlias);
- }
-
- public void addCartridgeSubscriptionAliases (Set<String> cartridgeSubscriptionAliases) {
- cartridgeSubscriptionAliases.addAll(cartridgeSubscriptionAliases);
- }
-
- public void addGroupSubscriptionAlias (String groupSubscriptionAlias) {
- groupSubscriptionAliases.add(groupSubscriptionAlias);
- }
-
- public void addGroupSubscriptionAliases (Set<String> groupSubscriptionAliases) {
- groupSubscriptionAliases.addAll(groupSubscriptionAliases);
- }
-
- public String getAppId() {
- return appId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CartridgeSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CartridgeSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CartridgeSubscription.java
deleted file mode 100644
index c649b41..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CartridgeSubscription.java
+++ /dev/null
@@ -1,430 +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.manager.subscription;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.manager.utils.ApplicationManagementUtil;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-import java.io.Serializable;
-import java.util.*;
-
-public abstract class CartridgeSubscription implements Serializable {
-
-
- private static final long serialVersionUID = -5197430500059231924L;
- private static Log log = LogFactory.getLog(CartridgeSubscription.class);
- private int subscriptionId;
- private String type;
- private String alias;
- private String autoscalingPolicyName;
- private String deploymentPolicyName;
- private Subscriber subscriber;
- private Repository repository;
- private CartridgeInfo cartridgeInfo;
- private PayloadData payloadData;
- private Cluster cluster;
- private String lbClusterId;
- private String subscriptionStatus;
- //private String serviceStatus;
- private String mappedDomain;
- //private List<String> connectedSubscriptionAliases;
- private String subscriptionKey;
- private SubscriptionTenancyBehaviour subscriptionTenancyBehaviour;
- private Map<String, SubscriptionDomain> subscriptionDomainMap;
-
- /**
- * Constructor
- *
- * @param cartridgeInfo CartridgeInfo instance
- * @param subscriptionTenancyBehaviour SubscriptionTenancyBehaviour instance
- */
- public CartridgeSubscription(CartridgeInfo cartridgeInfo, SubscriptionTenancyBehaviour subscriptionTenancyBehaviour) {
-
- this.setCartridgeInfo(cartridgeInfo);
- this.setType(cartridgeInfo.getType());
- this.setCluster(new Cluster());
- getCluster().setClusterDomain("");
- getCluster().setClusterSubDomain(CartridgeConstants.DEFAULT_SUBDOMAIN);
- getCluster().setMgtClusterDomain("");
- getCluster().setMgtClusterSubDomain(CartridgeConstants.DEFAULT_MGT_SUBDOMAIN);
- getCluster().setHostName(cartridgeInfo.getHostName());
- //this.setSubscriptionStatus(CartridgeConstants.SUBSCRIBED);
- //this.connectedSubscriptionAliases = new ArrayList<String>();
- this.setSubscriptionTenancyBehaviour(subscriptionTenancyBehaviour);
- this.subscriptionDomainMap = new HashMap<String, SubscriptionDomain>();
- }
-
- /**
- * Subscribes to this cartridge subscription
- *
- * @param subscriber Subscriber subscription
- * @param alias Alias of the cartridge subscription
- * @param autoscalingPolicy Auto scaling policy
- * @param deploymentPolicyName Deployment policy
- * @param repository Relevenat Repository subscription
- *
- * @throws org.apache.stratos.manager.exception.ADCException
- * @throws org.apache.stratos.manager.exception.PolicyException
- * @throws org.apache.stratos.manager.exception.UnregisteredCartridgeException
- * @throws org.apache.stratos.manager.exception.InvalidCartridgeAliasException
- * @throws org.apache.stratos.manager.exception.DuplicateCartridgeAliasException
- * @throws org.apache.stratos.manager.exception.RepositoryRequiredException
- * @throws org.apache.stratos.manager.exception.AlreadySubscribedException
- * @throws org.apache.stratos.manager.exception.RepositoryCredentialsRequiredException
- * @throws org.apache.stratos.manager.exception.InvalidRepositoryException
- * @throws org.apache.stratos.manager.exception.RepositoryTransportException
- */
- public void createSubscription (Subscriber subscriber, String alias, String autoscalingPolicy,
- String deploymentPolicyName, Repository repository)
- throws ADCException, PolicyException, UnregisteredCartridgeException, InvalidCartridgeAliasException,
- DuplicateCartridgeAliasException, RepositoryRequiredException, AlreadySubscribedException,
- RepositoryCredentialsRequiredException, InvalidRepositoryException, RepositoryTransportException {
-
- setSubscriber(subscriber);
- setAlias(alias);
- setAutoscalingPolicyName(autoscalingPolicy);
- setDeploymentPolicyName(deploymentPolicyName);
- setRepository(repository);
-
- setPayloadData(getSubscriptionTenancyBehaviour().create(getAlias(), getCluster(), getSubscriber(), getRepository(), getCartridgeInfo(),
- getSubscriptionKey(), getCustomPayloadEntries()));
- }
-
- public void addSubscriptionDomain(SubscriptionDomain subscriptionDomain) {
- subscriptionDomainMap.put(subscriptionDomain.getDomainName(), subscriptionDomain);
- }
-
- public void removeSubscriptionDomain(String domainName) {
- if(subscriptionDomainExists(domainName)) {
- subscriptionDomainMap.remove(domainName);
- }
- else {
- if(log.isWarnEnabled()) {
- log.warn("Subscription domain does not exist: " + domainName);
- }
- }
- }
-
- public boolean subscriptionDomainExists(String domainName) {
- return subscriptionDomainMap.containsKey(domainName);
- }
-
- public SubscriptionDomain getSubscriptionDomain(String domainName) {
- return subscriptionDomainMap.get(domainName);
- }
-
- public Collection<SubscriptionDomain> getSubscriptionDomains() {
- return Collections.unmodifiableCollection(subscriptionDomainMap.values());
- }
-
- /**
- * Unsubscribe from this cartridge subscription
- *
- * @throws ADCException
- * @throws NotSubscribedException
- */
- public void removeSubscription() throws ADCException, NotSubscribedException {
-
- getSubscriptionTenancyBehaviour().remove(getCluster().getClusterDomain(), getAlias());
- cleanupSubscription();
- }
-
- /**
- * Registers the subscription
- *
- * @param properties Any additional properties needed
- *
- * @param persistence
- * @return CartridgeSubscriptionInfo subscription populated with relevant data
- * @throws ADCException
- * @throws UnregisteredCartridgeException
- */
- public CartridgeSubscriptionInfo registerSubscription(Properties properties, Persistence persistence)
- throws ADCException, UnregisteredCartridgeException {
-
- // Properties props = new Properties();
- //props.setProperties(getCartridgeInfo().getProperties());
-
- getSubscriptionTenancyBehaviour().register (getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(),
- getDeploymentPolicyName(), properties, persistence);
-
- return ApplicationManagementUtil.createCartridgeSubscription(getCartridgeInfo(), getAutoscalingPolicyName(),
- getType(), getAlias(), getSubscriber().getTenantId(), getSubscriber().getTenantDomain(),
- getRepository(), getCluster().getHostName(), getCluster().getClusterDomain(), getCluster().getClusterSubDomain(),
- getCluster().getMgtClusterDomain(), getCluster().getMgtClusterSubDomain(), null, "PENDING", getSubscriptionKey());
- }
-
- /**
- * Connect cartridges
- *
- * @param connectingCartridgeAlias Alias of connecting cartridge
- */
- public void connect (String connectingCartridgeAlias) {
- //connectedSubscriptionAliases.add(connectingCartridgeAlias);
- }
-
- /**
- * Disconnect from the cartridge subscription given by disconnectingCartridgeAlias
- *
- * @param disconnectingCartridgeAlias Alias of the cartridge subscription to disconnect
- */
- public void disconnect (String disconnectingCartridgeAlias) {
- //connectedSubscriptionAliases.remove(disconnectingCartridgeAlias);
- }
-
- /**
- * Manages the repository for the cartridge subscription
- *
- * @param repoURL Repository URL
- * @param repoUserName Repository Username
- * @param repoUserPassword Repository password
- * @param privateRepo public/private repository
- *
- * @return Repository populated with relevant information or null of not repository is relevant to this cartridge
- * subscription
- * @throws ADCException
- * @throws RepositoryRequiredException
- * @throws RepositoryCredentialsRequiredException
- * @throws RepositoryTransportException
- * @throws InvalidRepositoryException
- */
- public abstract Repository manageRepository (String repoURL, String repoUserName, String repoUserPassword,
- boolean privateRepo) throws ADCException, RepositoryRequiredException, RepositoryCredentialsRequiredException,
- RepositoryTransportException, InvalidRepositoryException;
-
- /**
- * Cleans up the subscription information after unsubscribing
- *
- * @throws ADCException
- */
- protected void cleanupSubscription () throws ADCException {
-
-
- }
-
- public Map<String, String> getCustomPayloadEntries () {
-
- //no custom payload entries by default
- return null;
- }
-
- public String getType() {
- return type;
- }
-
- public String getAlias() {
- return alias;
- }
-
- public Subscriber getSubscriber() {
- return subscriber;
- }
-
- public Repository getRepository() {
- return repository;
- }
-
- /*public List<String> getConnectedSubscriptionAliases() {
- return connectedSubscriptionAliases;
- }*/
-
- public CartridgeInfo getCartridgeInfo() {
- return cartridgeInfo;
- }
-
- public String getHostName() {
- return getCluster().getHostName();
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public String getClusterDomain() {
- return getCluster().getClusterDomain();
- }
-
- public void setClusterDomain(String clusterDomain) {
- getCluster().setClusterDomain(clusterDomain);
- }
-
- public String getClusterSubDomain() {
- return getCluster().getClusterSubDomain();
- }
-
- public void setClusterSubDomain(String clusterSubDomain) {
- getCluster().setClusterSubDomain(clusterSubDomain);
- }
-
- public String getMgtClusterDomain() {
- return getCluster().getMgtClusterDomain();
- }
-
- public void setMgtClusterDomain(String mgtClusterDomain) {
- getCluster().setMgtClusterDomain(mgtClusterDomain);
- }
-
- public String getMgtClusterSubDomain() {
- return getCluster().getMgtClusterSubDomain();
- }
-
- public void setMgtClusterSubDomain(String mgtClusterSubDomain) {
- getCluster().setMgtClusterSubDomain(mgtClusterSubDomain);
- }
-
- public void setHostName(String hostName) {
- getCluster().setHostName(hostName);
- }
-
- public String getAutoscalingPolicyName() {
- return autoscalingPolicyName;
- }
-
- public void setAutoscalingPolicyName(String autoscalingPolicyName) {
- this.autoscalingPolicyName = autoscalingPolicyName;
- }
-
- public void setSubscriber(Subscriber subscriber) {
- this.subscriber = subscriber;
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
- public void setCartridgeInfo(CartridgeInfo cartridgeInfo) {
- this.cartridgeInfo = cartridgeInfo;
- }
-
- public PayloadData getPayloadData() {
- return payloadData;
- }
-
- public void setPayloadData(PayloadData payloadData) {
- this.payloadData = payloadData;
- }
-
- public int getSubscriptionId() {
- return subscriptionId;
- }
-
- public void setSubscriptionId(int subscriptionId) {
- this.subscriptionId = subscriptionId;
- }
-
- public String getMappedDomain() {
- return mappedDomain;
- }
-
- public void setMappedDomain(String mappedDomain) {
- this.mappedDomain = mappedDomain;
- }
-
- public String getSubscriptionStatus() {
- return subscriptionStatus;
- }
-
- public void setSubscriptionStatus(String subscriptionStatus) {
- this.subscriptionStatus = subscriptionStatus;
- }
-
- public String getSubscriptionKey() {
- return subscriptionKey;
- }
-
- public void setSubscriptionKey(String subscriptionKey) {
- this.subscriptionKey = subscriptionKey;
- }
-
- public Cluster getCluster() {
- return cluster;
- }
-
- public void setCluster(Cluster cluster) {
- this.cluster = cluster;
- }
-
- public String getDeploymentPolicyName() {
- return deploymentPolicyName;
- }
-
- public void setDeploymentPolicyName(String deploymentPolicyName) {
- this.deploymentPolicyName = deploymentPolicyName;
- }
-
- public SubscriptionTenancyBehaviour getSubscriptionTenancyBehaviour() {
- return subscriptionTenancyBehaviour;
- }
-
- public void setSubscriptionTenancyBehaviour(SubscriptionTenancyBehaviour subscriptionTenancyBehaviour) {
- this.subscriptionTenancyBehaviour = subscriptionTenancyBehaviour;
- }
-
- public boolean equals(Object other) {
-
- if(this == other) {
- return true;
- }
- if(!(other instanceof CartridgeSubscription)) {
- return false;
- }
-
- CartridgeSubscription that = (CartridgeSubscription)other;
- return ((this.type.equals(that.type)) && (this.alias.equals(that.alias)));
- }
-
- public int hashCode () {
-
- return type.hashCode() + alias.hashCode();
- }
-
- @Override
- public String toString() {
- return "CartridgeSubscription [subscriptionId=" + subscriptionId + ", type=" + type +
- ", alias=" + alias + ", autoscalingPolicyName=" + autoscalingPolicyName +
- ", deploymentPolicyName=" + deploymentPolicyName + ", subscriber=" + subscriber +
- ", repository=" + repository + ", cartridgeInfo=" + cartridgeInfo + ", payload=" +
- payloadData + ", cluster=" + cluster + "]" + ", subscriptionDomainMap=" + subscriptionDomainMap.toString();
- }
-
- public String getLbClusterId() {
- return lbClusterId;
- }
-
- public void setLbClusterId(String lbClusterId) {
- this.lbClusterId = lbClusterId;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/DataCartridgeSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/DataCartridgeSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/DataCartridgeSubscription.java
deleted file mode 100644
index d1bf60f..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/DataCartridgeSubscription.java
+++ /dev/null
@@ -1,116 +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.manager.subscription;
-
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo;
-import org.apache.stratos.manager.dao.DataCartridge;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.manager.utils.ApplicationManagementUtil;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class DataCartridgeSubscription extends CartridgeSubscription {
-
- private String host;
- private String username;
- private String password;
-
- /**
- * Constructor
- *
- * @param cartridgeInfo CartridgeInfo instance
- * @param subscriptionTenancyBehaviour SubscriptionTenancyBehaviour instance
- */
- public DataCartridgeSubscription(CartridgeInfo cartridgeInfo, SubscriptionTenancyBehaviour
- subscriptionTenancyBehaviour) {
-
- super(cartridgeInfo, subscriptionTenancyBehaviour);
- setDBHost("localhost");
- setDBUsername("root");
- setDBPassword(ApplicationManagementUtil.generatePassword());
- }
-
- @Override
- public CartridgeSubscriptionInfo registerSubscription(Properties properties, Persistence persistence) throws ADCException,
- UnregisteredCartridgeException {
-
- getSubscriptionTenancyBehaviour().register (getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(),
- getDeploymentPolicyName(), properties, persistence);
-
- DataCartridge dataCartridge = new DataCartridge();
- dataCartridge.setUserName(getDBUsername());
- dataCartridge.setPassword(getDBPassword());
- dataCartridge.setDataCartridgeType(getType());
-
- return ApplicationManagementUtil.createCartridgeSubscription(getCartridgeInfo(), getAutoscalingPolicyName(),
- getType(), getAlias(), getSubscriber().getTenantId(), getSubscriber().getTenantDomain(),
- getRepository(), getCluster().getHostName(), getCluster().getClusterDomain(), getCluster().getClusterSubDomain(),
- getCluster().getMgtClusterDomain(), getCluster().getMgtClusterSubDomain(), dataCartridge, "PENDING",getSubscriptionKey());
- }
-
- public Repository manageRepository (String repoURL, String repoUserName, String repoUserPassword,
- boolean privateRepo) {
-
- //no repository for data cartridge instances
- return null;
- }
-
- @Override
- public Map<String, String> getCustomPayloadEntries() {
-
- Map<String, String> payloadEntriesMap = new HashMap<String, String>();
- payloadEntriesMap.put("DB_HOST", host);
- payloadEntriesMap.put("DB_USER", username);
- payloadEntriesMap.put("MYSQL_PASSWORD", password);
-
- return payloadEntriesMap;
- }
-
- public String getDBHost() {
- return host;
- }
-
- public void setDBHost(String host) {
- this.host = host;
- }
-
- public String getDBUsername() {
- return username;
- }
-
- public void setDBUsername(String username) {
- this.username = username;
- }
-
- public String getDBPassword() {
- return password;
- }
-
- public void setDBPassword(String password) {
- this.password = password;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/FrameworkCartridgeSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/FrameworkCartridgeSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/FrameworkCartridgeSubscription.java
deleted file mode 100644
index 2501da3..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/FrameworkCartridgeSubscription.java
+++ /dev/null
@@ -1,62 +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.manager.subscription;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-
-
-public class FrameworkCartridgeSubscription extends CartridgeSubscription {
-
- private static Log log = LogFactory.getLog(FrameworkCartridgeSubscription.class);
- private static final long serialVersionUID = 1633832232416272756L;
-
- /**
- * Constructor
- *
- * @param cartridgeInfo CartridgeInfo instance
- * @param subscriptionTenancyBehaviour SubscriptionTenancyBehaviour instance
- */
- public FrameworkCartridgeSubscription(CartridgeInfo cartridgeInfo, SubscriptionTenancyBehaviour
- subscriptionTenancyBehaviour) {
- super(cartridgeInfo, subscriptionTenancyBehaviour);
- }
-
- public Repository manageRepository (String repoURL, String repoUserName, String repoUserPassword,
- boolean privateRepo)
-
- throws ADCException, RepositoryRequiredException, RepositoryCredentialsRequiredException,
- RepositoryTransportException, InvalidRepositoryException {
-
- log.info("External REPO URL is provided as [" + repoURL + "]");
-
- Repository repository = new Repository();
- repository.setUrl(repoURL);
- repository.setUserName(repoUserName);
- repository.setPassword(repoUserPassword);
- repository.setPrivateRepository(privateRepo);
-
- return repository;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/GroupSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/GroupSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/GroupSubscription.java
deleted file mode 100644
index 7b0f382..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/GroupSubscription.java
+++ /dev/null
@@ -1,73 +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.manager.subscription;
-
-import org.apache.stratos.manager.subscriber.Subscriber;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-
-public class GroupSubscription implements Serializable {
-
- private String name;
-
- private String groupAlias;
-
- private Set<String> cartridgeSubscriptionAliases;
-
- private Set<String> groupSubscriptionAliases;
-
- public GroupSubscription (String name, String groupAlias) {
-
- this.name = name;
- this.groupAlias = groupAlias;
- cartridgeSubscriptionAliases = new HashSet<String>();
- groupSubscriptionAliases = new HashSet<String>();
- }
-
- public Set<String> getGroupSubscriptionAliases() {
- return groupSubscriptionAliases;
- }
-
- public void addCartridgeSubscriptionAlias (String cartridgeSubscriptionAlias) {
- cartridgeSubscriptionAliases.add(cartridgeSubscriptionAlias);
- }
-
- public void addGroupSubscriptionAlias (String groupSubscriptionAlias) {
- groupSubscriptionAliases.add(groupSubscriptionAlias);
- }
-
- public void addCartridgeSubscriptionAliases (Set<String> cartridgeSubscriptionAliases) {
- cartridgeSubscriptionAliases.addAll(cartridgeSubscriptionAliases);
- }
-
- public void addGroupSubscriptionAliases (Set<String> groupSubscriptionAliases) {
- groupSubscriptionAliases.addAll(groupSubscriptionAliases);
- }
-
- public String getGroupAlias() {
- return groupAlias;
- }
-
- public String getName() {
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/InternalRepoBasedCartridgeSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/InternalRepoBasedCartridgeSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/InternalRepoBasedCartridgeSubscription.java
deleted file mode 100644
index 57e5349..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/InternalRepoBasedCartridgeSubscription.java
+++ /dev/null
@@ -1,90 +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.manager.subscription;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.InvalidRepositoryException;
-import org.apache.stratos.manager.exception.RepositoryCredentialsRequiredException;
-import org.apache.stratos.manager.exception.RepositoryRequiredException;
-import org.apache.stratos.manager.exception.RepositoryTransportException;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.service.RepositoryInfoBean;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.apache.stratos.manager.utils.RepositoryCreator;
-
-public class InternalRepoBasedCartridgeSubscription extends CartridgeSubscription {
-
- /**
- *
- */
- private static final long serialVersionUID = -1869600699603408517L;
- private static final Log log = LogFactory.getLog(InternalRepoBasedCartridgeSubscription.class);
-
- public InternalRepoBasedCartridgeSubscription(CartridgeInfo cartridgeInfo,
- SubscriptionTenancyBehaviour subscriptionTenancyBehaviour) {
- super(cartridgeInfo, subscriptionTenancyBehaviour);
- }
-
- @Override
- public Repository manageRepository(String repoURL, String repoUserName,
- String repoUserPassword, boolean privateRepo) throws ADCException,
- RepositoryRequiredException,
- RepositoryCredentialsRequiredException,
- RepositoryTransportException, InvalidRepositoryException {
-
- if(log.isDebugEnabled()) {
- log.debug("Managing internal repo for repo URL: " + repoURL);
- }
-
- Repository repository = null;
- String defaultRepoUserName = System.getProperty(CartridgeConstants.INTERNAL_GIT_USERNAME);
- String defaultRepoPassword = System.getProperty(CartridgeConstants.INTERNAL_GIT_PASSWORD);
- String[] dirArray = {"test"};
-
- if (repoURL != null && !repoURL.equalsIgnoreCase("null") && !repoURL.isEmpty()) {
- repository = new Repository();
- repository.setUrl(repoURL);
- repository.setUserName(defaultRepoUserName);
- repository.setPassword(defaultRepoPassword);
- return repository;
- }
-
- // Repo URL will be generated inside createInternalRepository method
- RepositoryInfoBean repoInfoBean = new RepositoryInfoBean(repoURL, getAlias(), getSubscriber().getTenantDomain(),
- defaultRepoUserName, defaultRepoPassword, dirArray);
- RepositoryCreator repoCreator = new RepositoryCreator(repoInfoBean);
- try {
- repository = repoCreator.createInternalRepository();
- } catch (Exception e) {
- String msg = "Error occurred in creating internal repository. ";
- log.error( msg + e.getMessage());
- throw new ADCException(msg);
- }
- return repository;
-
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/LBCartridgeSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/LBCartridgeSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/LBCartridgeSubscription.java
deleted file mode 100644
index 31d1f2f..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/LBCartridgeSubscription.java
+++ /dev/null
@@ -1,112 +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.manager.subscription;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.lb.category.LoadBalancerCategory;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.manager.utils.ApplicationManagementUtil;
-
-
-public class LBCartridgeSubscription extends CartridgeSubscription {
-
- private LoadBalancerCategory loadBalancerCategory;
- private static Log log = LogFactory.getLog(LBCartridgeSubscription.class);
-
- /**
- * Constructor
- *
- * @param cartridgeInfo CartridgeInfo instance
- * @param subscriptionTenancyBehaviour SubscriptionTenancyBehaviour instance
- * @param loadBalancerCategory LoadBalancerCategory instance
- */
- public LBCartridgeSubscription(CartridgeInfo cartridgeInfo, SubscriptionTenancyBehaviour
- subscriptionTenancyBehaviour, LoadBalancerCategory loadBalancerCategory) {
-
- super(cartridgeInfo, subscriptionTenancyBehaviour);
- setLoadBalancerCategory(loadBalancerCategory);
- }
-
- public void createSubscription (Subscriber subscriber, String alias, String autoscalingPolicy,
- String deploymentPolicyName, Repository repository)
- throws ADCException, PolicyException, UnregisteredCartridgeException, InvalidCartridgeAliasException,
- DuplicateCartridgeAliasException, RepositoryRequiredException, AlreadySubscribedException,
- RepositoryCredentialsRequiredException, InvalidRepositoryException, RepositoryTransportException {
-
- setSubscriber(subscriber);
- setAlias(alias);
- setAutoscalingPolicyName(autoscalingPolicy);
- setDeploymentPolicyName(deploymentPolicyName);
- setRepository(repository);
- setPayloadData(getLoadBalancerCategory().create(getAlias(), getCluster(), getSubscriber(), getRepository(), getCartridgeInfo(),
- getSubscriptionKey(), getCustomPayloadEntries()));
- // If LB subscription is for MT service, payload data should not be set
-// if(!loadBalancerCategory.isLoadBalancedServiceMultiTenant()) {
-// setPayloadData(getLoadBalancerCategory().create(getAlias(), getCluster(), getSubscriber(), getRepository(), getCartridgeInfo(),
-// getSubscriptionKey(), getCustomPayloadEntries()));
-// }
- }
-
-
- @Override
- public CartridgeSubscriptionInfo registerSubscription(Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException {
- //if(!loadBalancerCategory.isLoadBalancedServiceMultiTenant()) {
- //if(log.isDebugEnabled()) {
- //log.debug("Loadbalanced service is single tenant.");
- //}
- getLoadBalancerCategory().register (getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(),
- getDeploymentPolicyName(), properties, null);
- //}
-
- return ApplicationManagementUtil.createCartridgeSubscription(getCartridgeInfo(), getAutoscalingPolicyName(),
- getType(), getAlias(), getSubscriber().getTenantId(), getSubscriber().getTenantDomain(),
- getRepository(), getCluster().getHostName(), getCluster().getClusterDomain(), getCluster().getClusterSubDomain(),
- getCluster().getMgtClusterDomain(), getCluster().getMgtClusterSubDomain(), null, getSubscriptionStatus(), getSubscriptionKey());
- }
-
- @Override
- public void removeSubscription() throws ADCException, NotSubscribedException {
-
- getLoadBalancerCategory().remove(getCluster().getClusterDomain(), getAlias());;
- }
-
- public Repository manageRepository (String repoURL, String repoUserName, String repoUserPassword,
- boolean privateRepo) {
-
- //no repository for data cartridge instances
- return null;
- }
-
- public LoadBalancerCategory getLoadBalancerCategory() {
- return loadBalancerCategory;
- }
-
- public void setLoadBalancerCategory(LoadBalancerCategory loadBalancerCategory) {
- this.loadBalancerCategory = loadBalancerCategory;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/PersistenceContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/PersistenceContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/PersistenceContext.java
deleted file mode 100644
index b01e553..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/PersistenceContext.java
+++ /dev/null
@@ -1,78 +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.manager.subscription;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.Property;
-
-public class PersistenceContext {
-
- private static Log log = LogFactory.getLog(PersistenceContext.class);
-
- private Property persistanceRequiredProperty;
- private Property sizeProperty;
- private Property deleteOnTerminationProperty;
- private Property volumeIdProperty;
-
- public PersistenceContext () {
- persistanceRequiredProperty = new Property();
- sizeProperty = new Property();
- deleteOnTerminationProperty = new Property();
- volumeIdProperty = new Property();
- }
-
-
- public Property getPersistanceRequiredProperty() {
- return persistanceRequiredProperty;
- }
-
- public void setPersistanceRequiredProperty(String propertyName, String propertyValue) {
- this.persistanceRequiredProperty.setName(propertyName);
- this.persistanceRequiredProperty.setValue(propertyValue);
- }
-
- public Property getSizeProperty() {
- return sizeProperty;
- }
-
- public void setSizeProperty(String propertyName, String propertyValue) {
- this.sizeProperty.setName(propertyName);
- this.sizeProperty.setValue(propertyValue);
- }
-
- public Property getDeleteOnTerminationProperty() {
- return deleteOnTerminationProperty;
- }
-
- public void setDeleteOnTerminationProperty(String propertyName, String propertyValue) {
- this.deleteOnTerminationProperty.setName(propertyName);
- this.deleteOnTerminationProperty.setValue(propertyValue);
- }
-
- public Property getVolumeIdProperty() {
- return volumeIdProperty;
- }
-
- public void setVolumeIdProperty(String propertyName, String propertyValue) {
- this.volumeIdProperty.setName(propertyName);
- this.volumeIdProperty.setValue(propertyValue);
- }
-}
[11/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationSubscription.java
new file mode 100644
index 0000000..0e9af05
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ApplicationSubscription.java
@@ -0,0 +1,68 @@
+/*
+ * 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.manager.domain;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ApplicationSubscription implements Serializable {
+
+ private static final long serialVersionUID = 3380699449827682550L;
+
+ private static Log log = LogFactory.getLog(ApplicationSubscription.class);
+ private String appId;
+ private Set<String> cartridgeSubscriptionAliases;
+ private Set<String> groupSubscriptionAliases;
+
+ public ApplicationSubscription (String appId) {
+
+ this.appId = appId;
+ cartridgeSubscriptionAliases = new HashSet<String>();
+ groupSubscriptionAliases = new HashSet<String>();
+ }
+
+ public Set<String> getGroupSubscriptionAliases() {
+ return groupSubscriptionAliases;
+ }
+
+ public void addCartridgeSubscriptionAlias (String cartridgeSubscriptionAlias) {
+ cartridgeSubscriptionAliases.add(cartridgeSubscriptionAlias);
+ }
+
+ public void addCartridgeSubscriptionAliases (Set<String> cartridgeSubscriptionAliases) {
+ cartridgeSubscriptionAliases.addAll(cartridgeSubscriptionAliases);
+ }
+
+ public void addGroupSubscriptionAlias (String groupSubscriptionAlias) {
+ groupSubscriptionAliases.add(groupSubscriptionAlias);
+ }
+
+ public void addGroupSubscriptionAliases (Set<String> groupSubscriptionAliases) {
+ groupSubscriptionAliases.addAll(groupSubscriptionAliases);
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cartridge.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cartridge.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cartridge.java
new file mode 100644
index 0000000..f44d86d
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cartridge.java
@@ -0,0 +1,332 @@
+/*
+ * 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.manager.domain;
+
+import org.apache.stratos.cloud.controller.stub.domain.Persistence;
+import org.apache.stratos.cloud.controller.stub.domain.PortMapping;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Arrays;
+
+@XmlRootElement
+public class Cartridge implements Comparable<Cartridge> {
+
+ private String displayName;
+ private String description;
+ private boolean isPublic;
+ private String cartridgeAlias;
+ private String cartridgeType;
+ private int activeInstances;
+ private String status;
+ //private String ip;
+ private String provider;
+ private String category;
+ private String version;
+ private boolean multiTenant;
+ private boolean isLoadBalancer;
+ private String hostName;
+ //private String policy;
+ //private String policyDescription;
+ private String repoURL;
+ private String mappedDomain;
+
+ //DB specific
+ private String dbHost;
+ private String dbUserName;
+ private String password;
+
+ //LB cluster id
+ private String lbClusterId;
+
+ private String clusterId;
+
+ private String[] accessURLs;
+ private PortMapping[] portMappings;
+
+ private String defaultAutoscalingPolicy;
+
+ private String defaultDeploymentPolicy;
+
+ private boolean isPersistance;
+
+ private Persistence persistence;
+
+ private String serviceGroup;
+
+ 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 boolean getIsPublic() {
+ return isPublic;
+ }
+
+ public void setIsPublic(boolean isPublic) {
+ this.isPublic = isPublic;
+ }
+
+ public String getCartridgeAlias() {
+ return cartridgeAlias;
+ }
+
+ public void setCartridgeAlias(String cartridgeAlias) {
+ this.cartridgeAlias = cartridgeAlias;
+ }
+
+ public String getCartridgeType() {
+ return cartridgeType;
+ }
+
+ public void setCartridgeType(String cartridgeType) {
+ this.cartridgeType = cartridgeType;
+ }
+
+ public int getActiveInstances() {
+ return activeInstances;
+ }
+
+ public void setActiveInstances(int activeInstances) {
+ this.activeInstances = activeInstances;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /*public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }*/
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ 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 getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ /*public String getPolicy() {
+ return policy;
+ }
+
+ public void setPolicy(String policy) {
+ this.policy = policy;
+ }
+
+ public String getPolicyDescription() {
+ return policyDescription;
+ }
+
+ public void setPolicyDescription(String policyDescription) {
+ this.policyDescription = policyDescription;
+ }*/
+
+ public String getRepoURL() {
+ return repoURL;
+ }
+
+ public void setRepoURL(String repoURL) {
+ this.repoURL = repoURL;
+ }
+
+ public String getDbUserName() {
+ return dbUserName;
+ }
+
+ public String[] getAccessURLs() {
+ return accessURLs;
+ }
+
+ public void setAccessURLs(String[] accessURLs) {
+ if (accessURLs == null) {
+ this.accessURLs = new String[0];
+ } else {
+ this.accessURLs = Arrays.copyOf(accessURLs, accessURLs.length);
+ }
+ }
+
+ public void setDbUserName(String dbUserName) {
+ this.dbUserName = dbUserName;
+ }
+
+ public String getMappedDomain() {
+ return mappedDomain;
+ }
+
+ public void setMappedDomain(String mappedDomain) {
+ this.mappedDomain = mappedDomain;
+ }
+
+ @Override
+ public int compareTo(Cartridge o) {
+ int compare = 0;
+ if (cartridgeAlias != null && o.cartridgeAlias != null) {
+ compare = cartridgeAlias.compareTo(o.cartridgeAlias);
+ }
+ if (compare == 0 && cartridgeType != null && o.cartridgeType != null) {
+ compare = cartridgeType.compareTo(o.cartridgeType);
+ }
+ return compare;
+ }
+
+ public String getDbHost() {
+ return dbHost;
+ }
+
+ public void setDbHost(String dbHost) {
+ this.dbHost = dbHost;
+ }
+
+ public PortMapping[] getPortMappings() {
+ return portMappings;
+ }
+
+ public void setPortMappings(PortMapping[] portMappings) {
+ if (portMappings == null) {
+ this.portMappings = new PortMapping[0];
+ } else {
+ this.portMappings = Arrays.copyOf(portMappings, portMappings.length);
+ }
+ }
+
+ public String getLbClusterId() {
+ return lbClusterId;
+ }
+
+ public void setLbClusterId(String lbClusterId) {
+ this.lbClusterId = lbClusterId;
+ }
+
+ public boolean isLoadBalancer() {
+ return isLoadBalancer;
+ }
+
+ public void setLoadBalancer(boolean loadBalancer) {
+ this.isLoadBalancer = loadBalancer;
+ }
+
+ 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;
+ }
+
+ public boolean isPersistance() {
+ return isPersistance;
+ }
+
+ public void setPersistance(boolean persistance) {
+ isPersistance = persistance;
+ }
+
+ public Persistence getPersistence() {
+ return persistence;
+ }
+
+ public void setPersistence(Persistence persistence) {
+ this.persistence = persistence;
+ }
+
+ public String getServiceGroup() {
+ return serviceGroup;
+ }
+
+ public void setServiceGroup(String serviceGroup) {
+ this.serviceGroup = serviceGroup;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(String clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeDefinition.java
new file mode 100644
index 0000000..6fb01b6
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeDefinition.java
@@ -0,0 +1,67 @@
+/*
+ * 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.manager.domain;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class CartridgeDefinition implements Serializable {
+
+ private static final long serialVersionUID = 8968224678298479827L;
+
+ private String type;
+ private int cartridgeMin;
+ private int cartridgeMax;
+ private SubscribableInfo subscribableInfo;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public int getCartridgeMin() {
+ return cartridgeMin;
+ }
+
+ public void setCartridgeMin(int cartridgeMin) {
+ this.cartridgeMin = cartridgeMin;
+ }
+
+ public int getCartridgeMax() {
+ return cartridgeMax;
+ }
+
+ public void setCartridgeMax(int cartridgeMax) {
+ this.cartridgeMax = cartridgeMax;
+ }
+
+ public SubscribableInfo getSubscribableInfo() {
+ return subscribableInfo;
+ }
+
+ public void setSubscribableInfo(SubscribableInfo subscribableInfo) {
+ this.subscribableInfo = subscribableInfo;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeSubscriptionInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeSubscriptionInfo.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeSubscriptionInfo.java
new file mode 100644
index 0000000..8a68d8a
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeSubscriptionInfo.java
@@ -0,0 +1,200 @@
+/*
+ * 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.manager.domain;
+
+import org.apache.stratos.manager.domain.repository.Repository;
+
+import java.util.List;
+
+public class CartridgeSubscriptionInfo {
+
+ private int subscriptionId;
+ private int tenantId;
+ private String cartridge;
+ private String provider;
+ private String hostName;
+ private String policy;
+ private List<PortMapping> portMappings;
+ private String clusterDomain;
+ private String clusterSubdomain;
+ private Repository repository;
+ private String state;
+ private String alias;
+ private String tenantDomain;
+ private DataCartridge dataCartridge;
+ private String baseDirectory;
+ private String mappedDomain;
+ private String mgtClusterDomain;
+ private String mgtClusterSubDomain;
+ private String subscriptionKey;
+
+ public int getSubscriptionId() {
+ return subscriptionId;
+ }
+
+ public void setSubscriptionId(int subscriptionId) {
+ this.subscriptionId = subscriptionId;
+ }
+
+ public int getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(int tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getCartridge() {
+ return cartridge;
+ }
+
+ public void setCartridge(String cartridge) {
+ this.cartridge = cartridge;
+ }
+
+ public String getProvider() {
+ return provider;
+ }
+
+ public void setProvider(String provider) {
+ this.provider = provider;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getPolicy() {
+ return policy;
+ }
+
+ public void setPolicy(String policy) {
+ this.policy = policy;
+ }
+
+ public List<PortMapping> getPortMappings() {
+ return portMappings;
+ }
+
+ public void setPortMappings(List<PortMapping> portMappings) {
+ this.portMappings = portMappings;
+ }
+
+ public String getClusterDomain() {
+ return clusterDomain;
+ }
+
+ public void setClusterDomain(String clusterDomain) {
+ this.clusterDomain = clusterDomain;
+ }
+
+ public String getClusterSubdomain() {
+ return clusterSubdomain;
+ }
+
+ public void setClusterSubdomain(String clusterSubdomain) {
+ this.clusterSubdomain = clusterSubdomain;
+ }
+
+ public Repository getRepository() {
+ return repository;
+ }
+
+ public void setRepository(Repository repository) {
+ this.repository = repository;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public String getTenantDomain() {
+ return tenantDomain;
+ }
+
+ public void setTenantDomain(String tenantDomain) {
+ this.tenantDomain = tenantDomain;
+ }
+
+ public DataCartridge getDataCartridge() {
+ return dataCartridge;
+ }
+
+ public void setDataCartridge(DataCartridge dataCartridge) {
+ this.dataCartridge = dataCartridge;
+ }
+
+ public String getBaseDirectory() {
+ return baseDirectory;
+ }
+
+ public void setBaseDirectory(String baseDirectory) {
+ this.baseDirectory = baseDirectory;
+ }
+
+ public String getMappedDomain() {
+ return mappedDomain;
+ }
+
+ public void setMappedDomain(String mappedDomain) {
+ this.mappedDomain = mappedDomain;
+ }
+
+ public String getMgtClusterDomain() {
+ return mgtClusterDomain;
+ }
+
+ public void setMgtClusterDomain(String mgtClusterDomain) {
+ this.mgtClusterDomain = mgtClusterDomain;
+ }
+
+ public String getMgtClusterSubDomain() {
+ return mgtClusterSubDomain;
+ }
+
+ public void setMgtClusterSubDomain(String mgtClusterSubDomain) {
+ this.mgtClusterSubDomain = mgtClusterSubDomain;
+ }
+
+ public String getSubscriptionKey() {
+ return subscriptionKey;
+ }
+
+ public void setSubscriptionKey(String subscriptionKey) {
+ this.subscriptionKey = subscriptionKey;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeWrapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeWrapper.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeWrapper.java
new file mode 100644
index 0000000..a6bcbda
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/CartridgeWrapper.java
@@ -0,0 +1,52 @@
+/*
+ * 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.manager.domain;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.wso2.carbon.utils.Pageable;
+
+/**
+ * This class holds paginated information about cartridges
+ */
+public final class CartridgeWrapper implements Pageable {
+
+ private Cartridge[] cartridges;
+ private int numberOfPages;
+
+ public CartridgeWrapper() {
+ }
+
+ public int getNumberOfPages() {
+ return numberOfPages;
+ }
+
+ public void setNumberOfPages(int numberOfPages) {
+ this.numberOfPages = numberOfPages;
+ }
+
+ public <T> void set(List<T> items) {
+ this.cartridges = items.toArray(new Cartridge[items.size()]);
+ }
+
+ public Cartridge[] getCartridges() {
+ return cartridges != null ? Arrays.copyOf(cartridges, cartridges.length) : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cluster.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cluster.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cluster.java
new file mode 100644
index 0000000..065c28c
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Cluster.java
@@ -0,0 +1,97 @@
+/*
+ *
+ * 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.manager.domain;
+
+import java.io.Serializable;
+
+public class Cluster implements Serializable {
+ private static final long serialVersionUID = -1579127946734432357L;
+ private int id;
+ private String clusterDomain;
+ private String clusterSubDomain;
+ private String mgtClusterDomain;
+ private String mgtClusterSubDomain;
+ private String hostName;
+ private String serviceStatus;
+
+ public Cluster() {
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public String getClusterDomain() {
+ return clusterDomain;
+ }
+
+ public void setClusterDomain(String clusterDomain) {
+ this.clusterDomain = clusterDomain;
+ }
+
+ public String getClusterSubDomain() {
+ return clusterSubDomain;
+ }
+
+ public void setClusterSubDomain(String clusterSubDomain) {
+ this.clusterSubDomain = clusterSubDomain;
+ }
+
+ public String getMgtClusterDomain() {
+ return mgtClusterDomain;
+ }
+
+ public void setMgtClusterDomain(String mgtClusterDomain) {
+ this.mgtClusterDomain = mgtClusterDomain;
+ }
+
+ public String getMgtClusterSubDomain() {
+ return mgtClusterSubDomain;
+ }
+
+ public void setMgtClusterSubDomain(String mgtClusterSubDomain) {
+ this.mgtClusterSubDomain = mgtClusterSubDomain;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getServiceStatus() {
+ return serviceStatus;
+ }
+
+ public void setServiceStatus(String serviceStatus) {
+ this.serviceStatus = serviceStatus;
+ }
+
+ public String toString () {
+ return clusterDomain;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ComponentDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ComponentDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ComponentDefinition.java
new file mode 100644
index 0000000..f4ff529
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ComponentDefinition.java
@@ -0,0 +1,40 @@
+package org.apache.stratos.manager.domain;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "components")
+public class ComponentDefinition implements Serializable {
+
+ private static final long serialVersionUID = -5932265453191494386L;
+
+ private List<GroupDefinition> groups;
+ private DependencyDefinitions dependencies;
+ private List<CartridgeDefinition> cartridges;
+
+ public List<GroupDefinition> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<GroupDefinition> groups) {
+ this.groups = groups;
+ }
+
+ public DependencyDefinitions getDependencies() {
+ return dependencies;
+ }
+
+ public void setDependencies(DependencyDefinitions dependencies) {
+ this.dependencies = dependencies;
+ }
+
+ public List<CartridgeDefinition> getCartridges() {
+ return cartridges;
+ }
+
+ public void setCartridges(List<CartridgeDefinition> cartridges) {
+ this.cartridges = cartridges;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DataCartridge.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DataCartridge.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DataCartridge.java
new file mode 100644
index 0000000..857baa9
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DataCartridge.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.manager.domain;
+
+public class DataCartridge {
+
+ private int id;
+ private String dataCartridgeType;
+ private String host;
+ private String userName;
+ private String password;
+
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+ public String getDataCartridgeType() {
+ return dataCartridgeType;
+ }
+ public void setDataCartridgeType(String dataCartridgeType) {
+ this.dataCartridgeType = dataCartridgeType;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DependencyDefinitions.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DependencyDefinitions.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DependencyDefinitions.java
new file mode 100644
index 0000000..3311ddb
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/DependencyDefinitions.java
@@ -0,0 +1,64 @@
+/*
+ * 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.manager.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+@XmlRootElement(name = "dependencies")
+public class DependencyDefinitions implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private List<String> startupOrders;
+
+ private List<String> scalingDependants;
+
+ private String terminationBehaviour;
+
+ public String getTerminationBehaviour() {
+ return terminationBehaviour;
+ }
+
+ public void setTerminationBehaviour(String terminationBehaviour) {
+ this.terminationBehaviour = terminationBehaviour;
+ }
+
+ public List<String> getStartupOrders() {
+ return startupOrders;
+ }
+
+ public void setStartupOrders(List<String> startupOrders) {
+ this.startupOrders = startupOrders;
+ }
+
+ public List<String> getScalingDependants() {
+ return scalingDependants;
+ }
+
+ public void setScalingDependants(List<String> scalingDependants) {
+ this.scalingDependants = scalingDependants;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/GroupDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/GroupDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/GroupDefinition.java
new file mode 100644
index 0000000..8cca509
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/GroupDefinition.java
@@ -0,0 +1,101 @@
+/*
+ * 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.manager.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+@XmlRootElement(name = "groups")
+public class GroupDefinition implements Serializable {
+
+ private static final long serialVersionUID = 7261380706841894892L;
+
+ private String name;
+
+ private String alias;
+
+ private int groupMinInstances;
+
+ private int groupMaxInstances;
+
+ public boolean isGroupScalingEnabled;
+
+ private List<CartridgeDefinition> cartridges;
+
+ private List<GroupDefinition> groups;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public int getGroupMinInstances() {
+ return groupMinInstances;
+ }
+
+ public void setGroupMinInstances(int groupMinInstances) {
+ this.groupMinInstances = groupMinInstances;
+ }
+
+ public int getGroupMaxInstances() {
+ return groupMaxInstances;
+ }
+
+ public void setGroupMaxInstances(int groupMaxInstances) {
+ this.groupMaxInstances = groupMaxInstances;
+ }
+
+ public boolean isGroupScalingEnabled() {
+ return isGroupScalingEnabled;
+ }
+
+ public void setGroupScalingEnabled(boolean isGroupScalingEnabled) {
+ this.isGroupScalingEnabled = isGroupScalingEnabled;
+ }
+
+ public List<CartridgeDefinition> getCartridges() {
+ return cartridges;
+ }
+
+ public void setCartridges(List<CartridgeDefinition> cartridges) {
+ this.cartridges = cartridges;
+ }
+
+ public List<GroupDefinition> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<GroupDefinition> groups) {
+ this.groups = groups;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Policy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Policy.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Policy.java
new file mode 100644
index 0000000..39354df
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/Policy.java
@@ -0,0 +1,148 @@
+/*
+ * 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.manager.domain;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+public class Policy implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String description;
+ private boolean defaultPolicy;
+
+ private Integer minAppInstances;
+ private Integer maxAppInstances;
+ private Integer maxRequestsPerSecond;
+ private BigDecimal alarmingUpperRate;
+ private BigDecimal alarmingLowerRate;
+ private BigDecimal scaleDownFactor;
+ private Integer roundsToAverage;
+
+ public Policy() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isDefaultPolicy() {
+ return defaultPolicy;
+ }
+
+ public void setDefaultPolicy(boolean defaultPolicy) {
+ this.defaultPolicy = defaultPolicy;
+ }
+
+ public Integer getMinAppInstances() {
+ return minAppInstances;
+ }
+
+ public void setMinAppInstances(Integer minAppInstances) {
+ this.minAppInstances = minAppInstances;
+ }
+
+ public Integer getMaxAppInstances() {
+ return maxAppInstances;
+ }
+
+ public void setMaxAppInstances(Integer maxAppInstances) {
+ this.maxAppInstances = maxAppInstances;
+ }
+
+ public Integer getMaxRequestsPerSecond() {
+ return maxRequestsPerSecond;
+ }
+
+ public void setMaxRequestsPerSecond(Integer maxRequestsPerSecond) {
+ this.maxRequestsPerSecond = maxRequestsPerSecond;
+ }
+
+ public BigDecimal getAlarmingUpperRate() {
+ return alarmingUpperRate;
+ }
+
+ public void setAlarmingUpperRate(BigDecimal alarmingUpperRate) {
+ this.alarmingUpperRate = alarmingUpperRate;
+ }
+
+ public BigDecimal getAlarmingLowerRate() {
+ return alarmingLowerRate;
+ }
+
+ public void setAlarmingLowerRate(BigDecimal alarmingLowerRate) {
+ this.alarmingLowerRate = alarmingLowerRate;
+ }
+
+ public BigDecimal getScaleDownFactor() {
+ return scaleDownFactor;
+ }
+
+ public void setScaleDownFactor(BigDecimal scaleDownFactor) {
+ this.scaleDownFactor = scaleDownFactor;
+ }
+
+ public Integer getRoundsToAverage() {
+ return roundsToAverage;
+ }
+
+ public void setRoundsToAverage(Integer roundsToAverage) {
+ this.roundsToAverage = roundsToAverage;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof Policy))
+ return false;
+ Policy other = (Policy) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PolicyDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PolicyDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PolicyDefinition.java
new file mode 100644
index 0000000..b87d935
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PolicyDefinition.java
@@ -0,0 +1,83 @@
+/*
+ * 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.manager.domain;
+
+import java.io.Serializable;
+
+public class PolicyDefinition implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private String description;
+ private boolean defaultPolicy;
+
+ public PolicyDefinition() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isDefaultPolicy() {
+ return defaultPolicy;
+ }
+
+ public void setDefaultPolicy(boolean defaultPolicy) {
+ this.defaultPolicy = defaultPolicy;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof PolicyDefinition))
+ return false;
+ PolicyDefinition other = (PolicyDefinition) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PortMapping.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PortMapping.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PortMapping.java
new file mode 100644
index 0000000..4a1a2a9
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PortMapping.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.manager.domain;
+
+public class PortMapping {
+ private int id;
+ private String type;
+ private String primaryPort;
+ private String proxyPort;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getPrimaryPort() {
+ return primaryPort;
+ }
+
+ public void setPrimaryPort(String primaryPort) {
+ this.primaryPort = primaryPort;
+ }
+
+ public String getProxyPort() {
+ return proxyPort;
+ }
+
+ public void setProxyPort(String proxyPort) {
+ this.proxyPort = proxyPort;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PropertyBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PropertyBean.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PropertyBean.java
new file mode 100644
index 0000000..4192644
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/PropertyBean.java
@@ -0,0 +1,49 @@
+/*
+ * 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.manager.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+@XmlRootElement(name = "property")
+public class PropertyBean implements Serializable {
+
+ private static final long serialVersionUID = 5756598782384376873L;
+
+ private String name;
+
+ private String value;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryCredentials.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryCredentials.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryCredentials.java
new file mode 100644
index 0000000..4a6d323
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryCredentials.java
@@ -0,0 +1,48 @@
+package org.apache.stratos.manager.domain;
+/*
+ *
+ * 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.
+ *
+*/
+
+
+public class RepositoryCredentials {
+
+ private String url;
+ private String userName;
+ private String password;
+ public String getUrl() {
+ return url;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInfoBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInfoBean.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInfoBean.java
new file mode 100644
index 0000000..3426f18
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInfoBean.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.manager.domain;
+
+import java.util.Arrays;
+
+/**
+ *
+ */
+public class RepositoryInfoBean {
+
+ private String repoURL;
+ private String cartridgeAlias;
+ private String tenantDomain;
+ private String userName;
+ private String password;
+ private String[] dirArray;
+
+ public RepositoryInfoBean(String repoURL, String cartridgeAlias, String tenantDomain,
+ String userName, String password, String[] dirArray) {
+ this.repoURL = repoURL;
+ this.cartridgeAlias = cartridgeAlias;
+ this.tenantDomain = tenantDomain;
+ this.userName = userName;
+ this.setPassword(password);
+ setDirArray(dirArray);
+ }
+ public String getRepoURL() {
+ return repoURL;
+ }
+ public void setRepoURL(String repoURL) {
+ this.repoURL = repoURL;
+ }
+ public String getCartridgeAlias() {
+ return cartridgeAlias;
+ }
+ public void setCartridgeAlias(String cartridgeAlias) {
+ this.cartridgeAlias = cartridgeAlias;
+ }
+ public String getTenantDomain() {
+ return tenantDomain;
+ }
+ public void setTenantDomain(String tenantDomain) {
+ this.tenantDomain = tenantDomain;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+ public String[] getDirArray() {
+ return dirArray;
+ }
+ public void setDirArray(String[] dirArray) {
+ if(dirArray == null) {
+ this.dirArray = new String[0];
+ } else {
+ this.dirArray = Arrays.copyOf(dirArray, dirArray.length);
+ }
+ }
+ public String getPassword() {
+ return password;
+ }
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInformation.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInformation.java
new file mode 100644
index 0000000..9fd0f9e
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/RepositoryInformation.java
@@ -0,0 +1,51 @@
+/*
+ * 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.manager.domain;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+public class RepositoryInformation implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String repoURL;
+ private String[] refName;
+
+ public String getRepoURL() {
+ return repoURL;
+ }
+
+ public void setRepoURL(String repoURL) {
+ this.repoURL = repoURL;
+ }
+
+ public String[] getRefName() {
+ return refName;
+ }
+
+ public void setRefName(String[] refName) {
+ if(refName == null) {
+ this.refName = new String[0];
+ } else {
+ this.refName = Arrays.copyOf(refName, refName.length);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ServiceGroupDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ServiceGroupDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ServiceGroupDefinition.java
new file mode 100644
index 0000000..a490a8b
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/ServiceGroupDefinition.java
@@ -0,0 +1,70 @@
+/*
+ * 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.manager.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+import java.util.List;
+
+@XmlRootElement(name = "groups")
+public class ServiceGroupDefinition implements Serializable {
+
+ private String name;
+
+ private List<ServiceGroupDefinition> groups;
+
+ private List<String> cartridges;
+
+ public boolean isGroupScalingEnabled;
+
+ private DependencyDefinitions dependencies;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<String> getCartridges() {
+ return cartridges;
+ }
+
+ public void setCartridges(List<String> cartridges) {
+ this.cartridges = cartridges;
+ }
+
+ public DependencyDefinitions getDependencies() {
+ return dependencies;
+ }
+
+ public void setDependencies(DependencyDefinitions dependencies) {
+ this.dependencies = dependencies;
+ }
+
+ public List<ServiceGroupDefinition> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<ServiceGroupDefinition> groups) {
+ this.groups = groups;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscribableInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscribableInfo.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscribableInfo.java
new file mode 100644
index 0000000..cdf404b
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscribableInfo.java
@@ -0,0 +1,131 @@
+/*
+ * 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.manager.domain;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "subscribableInfo")
+public class SubscribableInfo implements Serializable {
+
+ private static final long serialVersionUID = 8097432440778125606L;
+
+ private String alias;
+ private String deploymentPolicy;
+ private String autoscalingPolicy;
+ private String repoUrl;
+ private boolean privateRepo;
+ private String repoUsername;
+ private int maxMembers;
+ private int minMembers;
+ private String repoPassword;
+ private String[] dependencyAliases;
+ private List<PropertyBean> property;
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public String getDeploymentPolicy() {
+ return deploymentPolicy;
+ }
+
+ public void setDeploymentPolicy(String deploymentPolicy) {
+ this.deploymentPolicy = deploymentPolicy;
+ }
+
+ public String getAutoscalingPolicy() {
+ return autoscalingPolicy;
+ }
+
+ public void setAutoscalingPolicy(String autoscalingPolicy) {
+ this.autoscalingPolicy = autoscalingPolicy;
+ }
+
+ public String getRepoUrl() {
+ return repoUrl;
+ }
+
+ public void setRepoUrl(String repoUrl) {
+ this.repoUrl = repoUrl;
+ }
+
+ public boolean isPrivateRepo() {
+ return privateRepo;
+ }
+
+ public void setPrivateRepo(boolean privateRepo) {
+ this.privateRepo = privateRepo;
+ }
+
+ public String getRepoUsername() {
+ return repoUsername;
+ }
+
+ public void setRepoUsername(String repoUsername) {
+ this.repoUsername = repoUsername;
+ }
+
+ public String getRepoPassword() {
+ return repoPassword;
+ }
+
+ public void setRepoPassword(String repoPassword) {
+ this.repoPassword = repoPassword;
+ }
+
+ public String[] getDependencyAliases() {
+ return dependencyAliases;
+ }
+
+ public void setDependencyAliases(String[] dependencyAliases) {
+ this.dependencyAliases = dependencyAliases;
+ }
+
+ public List<PropertyBean> getProperty() {
+ return property;
+ }
+
+ public void setProperty(List<PropertyBean> property) {
+ this.property = property;
+ }
+
+ public int getMaxMembers() {
+ return maxMembers;
+ }
+
+ public void setMaxMembers(int maxMembers) {
+ this.maxMembers = maxMembers;
+ }
+
+ public int getMinMembers() {
+ return minMembers;
+ }
+
+ public void setMinMembers(int minMembers) {
+ this.minMembers = minMembers;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscriptionInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscriptionInfo.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscriptionInfo.java
new file mode 100644
index 0000000..0b536b3
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/SubscriptionInfo.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.manager.domain;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+@XmlRootElement
+public class SubscriptionInfo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String hostname;
+ private String repositoryURL;
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public String getRepositoryURL() {
+ return repositoryURL;
+ }
+
+ public void setRepositoryURL(String repositoryURL) {
+ this.repositoryURL = repositoryURL;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/repository/Repository.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/repository/Repository.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/repository/Repository.java
new file mode 100644
index 0000000..6231929
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/domain/repository/Repository.java
@@ -0,0 +1,87 @@
+/*
+ * 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.manager.domain.repository;
+
+import java.io.Serializable;
+
+public class Repository implements Serializable {
+
+ private static final long serialVersionUID = 8386330511938705573L;
+ private int id;
+ private String url;
+ private String userName;
+ private String password;
+ private boolean isPrivateRepository;
+ private boolean commitEnabled;
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public boolean isPrivateRepository() {
+ return isPrivateRepository;
+ }
+
+ public void setPrivateRepository(boolean privateRepository) {
+ isPrivateRepository = privateRepository;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return "Repository [id=" + id + ", url=" + url + ", userName=" + userName +
+ ", isPrivateRepository=" + isPrivateRepository + "]";
+ }
+
+ public boolean isCommitEnabled() {
+ return commitEnabled;
+ }
+
+ public void setCommitEnabled(boolean commitEnabled) {
+ this.commitEnabled = commitEnabled;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Cartridge.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Cartridge.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Cartridge.java
deleted file mode 100644
index 865dfdf..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Cartridge.java
+++ /dev/null
@@ -1,332 +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.manager.dto;
-
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.cloud.controller.stub.domain.PortMapping;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.util.Arrays;
-
-@XmlRootElement
-public class Cartridge implements Comparable<Cartridge> {
-
- private String displayName;
- private String description;
- private boolean isPublic;
- private String cartridgeAlias;
- private String cartridgeType;
- private int activeInstances;
- private String status;
- //private String ip;
- private String provider;
- private String category;
- private String version;
- private boolean multiTenant;
- private boolean isLoadBalancer;
- private String hostName;
- //private String policy;
- //private String policyDescription;
- private String repoURL;
- private String mappedDomain;
-
- //DB specific
- private String dbHost;
- private String dbUserName;
- private String password;
-
- //LB cluster id
- private String lbClusterId;
-
- private String clusterId;
-
- private String[] accessURLs;
- private PortMapping[] portMappings;
-
- private String defaultAutoscalingPolicy;
-
- private String defaultDeploymentPolicy;
-
- private boolean isPersistance;
-
- private Persistence persistence;
-
- private String serviceGroup;
-
- 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 boolean getIsPublic() {
- return isPublic;
- }
-
- public void setIsPublic(boolean isPublic) {
- this.isPublic = isPublic;
- }
-
- public String getCartridgeAlias() {
- return cartridgeAlias;
- }
-
- public void setCartridgeAlias(String cartridgeAlias) {
- this.cartridgeAlias = cartridgeAlias;
- }
-
- public String getCartridgeType() {
- return cartridgeType;
- }
-
- public void setCartridgeType(String cartridgeType) {
- this.cartridgeType = cartridgeType;
- }
-
- public int getActiveInstances() {
- return activeInstances;
- }
-
- public void setActiveInstances(int activeInstances) {
- this.activeInstances = activeInstances;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- /*public String getIp() {
- return ip;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }*/
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- 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 getHostName() {
- return hostName;
- }
-
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
-
- /*public String getPolicy() {
- return policy;
- }
-
- public void setPolicy(String policy) {
- this.policy = policy;
- }
-
- public String getPolicyDescription() {
- return policyDescription;
- }
-
- public void setPolicyDescription(String policyDescription) {
- this.policyDescription = policyDescription;
- }*/
-
- public String getRepoURL() {
- return repoURL;
- }
-
- public void setRepoURL(String repoURL) {
- this.repoURL = repoURL;
- }
-
- public String getDbUserName() {
- return dbUserName;
- }
-
- public String[] getAccessURLs() {
- return accessURLs;
- }
-
- public void setAccessURLs(String[] accessURLs) {
- if (accessURLs == null) {
- this.accessURLs = new String[0];
- } else {
- this.accessURLs = Arrays.copyOf(accessURLs, accessURLs.length);
- }
- }
-
- public void setDbUserName(String dbUserName) {
- this.dbUserName = dbUserName;
- }
-
- public String getMappedDomain() {
- return mappedDomain;
- }
-
- public void setMappedDomain(String mappedDomain) {
- this.mappedDomain = mappedDomain;
- }
-
- @Override
- public int compareTo(Cartridge o) {
- int compare = 0;
- if (cartridgeAlias != null && o.cartridgeAlias != null) {
- compare = cartridgeAlias.compareTo(o.cartridgeAlias);
- }
- if (compare == 0 && cartridgeType != null && o.cartridgeType != null) {
- compare = cartridgeType.compareTo(o.cartridgeType);
- }
- return compare;
- }
-
- public String getDbHost() {
- return dbHost;
- }
-
- public void setDbHost(String dbHost) {
- this.dbHost = dbHost;
- }
-
- public PortMapping[] getPortMappings() {
- return portMappings;
- }
-
- public void setPortMappings(PortMapping[] portMappings) {
- if (portMappings == null) {
- this.portMappings = new PortMapping[0];
- } else {
- this.portMappings = Arrays.copyOf(portMappings, portMappings.length);
- }
- }
-
- public String getLbClusterId() {
- return lbClusterId;
- }
-
- public void setLbClusterId(String lbClusterId) {
- this.lbClusterId = lbClusterId;
- }
-
- public boolean isLoadBalancer() {
- return isLoadBalancer;
- }
-
- public void setLoadBalancer(boolean loadBalancer) {
- this.isLoadBalancer = loadBalancer;
- }
-
- 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;
- }
-
- public boolean isPersistance() {
- return isPersistance;
- }
-
- public void setPersistance(boolean persistance) {
- isPersistance = persistance;
- }
-
- public Persistence getPersistence() {
- return persistence;
- }
-
- public void setPersistence(Persistence persistence) {
- this.persistence = persistence;
- }
-
- public String getServiceGroup() {
- return serviceGroup;
- }
-
- public void setServiceGroup(String serviceGroup) {
- this.serviceGroup = serviceGroup;
- }
-
- public String getClusterId() {
- return clusterId;
- }
-
- public void setClusterId(String clusterId) {
- this.clusterId = clusterId;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/CartridgeWrapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/CartridgeWrapper.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/CartridgeWrapper.java
deleted file mode 100644
index fd73312..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/CartridgeWrapper.java
+++ /dev/null
@@ -1,52 +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.manager.dto;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.wso2.carbon.utils.Pageable;
-
-/**
- * This class holds paginated information about cartridges
- */
-public final class CartridgeWrapper implements Pageable {
-
- private Cartridge[] cartridges;
- private int numberOfPages;
-
- public CartridgeWrapper() {
- }
-
- public int getNumberOfPages() {
- return numberOfPages;
- }
-
- public void setNumberOfPages(int numberOfPages) {
- this.numberOfPages = numberOfPages;
- }
-
- public <T> void set(List<T> items) {
- this.cartridges = items.toArray(new Cartridge[items.size()]);
- }
-
- public Cartridge[] getCartridges() {
- return cartridges != null ? Arrays.copyOf(cartridges, cartridges.length) : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Policy.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Policy.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Policy.java
deleted file mode 100644
index 19493a5..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/Policy.java
+++ /dev/null
@@ -1,148 +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.manager.dto;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-public class Policy implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String name;
- private String description;
- private boolean defaultPolicy;
-
- private Integer minAppInstances;
- private Integer maxAppInstances;
- private Integer maxRequestsPerSecond;
- private BigDecimal alarmingUpperRate;
- private BigDecimal alarmingLowerRate;
- private BigDecimal scaleDownFactor;
- private Integer roundsToAverage;
-
- public Policy() {
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean isDefaultPolicy() {
- return defaultPolicy;
- }
-
- public void setDefaultPolicy(boolean defaultPolicy) {
- this.defaultPolicy = defaultPolicy;
- }
-
- public Integer getMinAppInstances() {
- return minAppInstances;
- }
-
- public void setMinAppInstances(Integer minAppInstances) {
- this.minAppInstances = minAppInstances;
- }
-
- public Integer getMaxAppInstances() {
- return maxAppInstances;
- }
-
- public void setMaxAppInstances(Integer maxAppInstances) {
- this.maxAppInstances = maxAppInstances;
- }
-
- public Integer getMaxRequestsPerSecond() {
- return maxRequestsPerSecond;
- }
-
- public void setMaxRequestsPerSecond(Integer maxRequestsPerSecond) {
- this.maxRequestsPerSecond = maxRequestsPerSecond;
- }
-
- public BigDecimal getAlarmingUpperRate() {
- return alarmingUpperRate;
- }
-
- public void setAlarmingUpperRate(BigDecimal alarmingUpperRate) {
- this.alarmingUpperRate = alarmingUpperRate;
- }
-
- public BigDecimal getAlarmingLowerRate() {
- return alarmingLowerRate;
- }
-
- public void setAlarmingLowerRate(BigDecimal alarmingLowerRate) {
- this.alarmingLowerRate = alarmingLowerRate;
- }
-
- public BigDecimal getScaleDownFactor() {
- return scaleDownFactor;
- }
-
- public void setScaleDownFactor(BigDecimal scaleDownFactor) {
- this.scaleDownFactor = scaleDownFactor;
- }
-
- public Integer getRoundsToAverage() {
- return roundsToAverage;
- }
-
- public void setRoundsToAverage(Integer roundsToAverage) {
- this.roundsToAverage = roundsToAverage;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Policy))
- return false;
- Policy other = (Policy) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/PolicyDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/PolicyDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/PolicyDefinition.java
deleted file mode 100644
index fccc62e..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/PolicyDefinition.java
+++ /dev/null
@@ -1,83 +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.manager.dto;
-
-import java.io.Serializable;
-
-public class PolicyDefinition implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String name;
- private String description;
- private boolean defaultPolicy;
-
- public PolicyDefinition() {
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public boolean isDefaultPolicy() {
- return defaultPolicy;
- }
-
- public void setDefaultPolicy(boolean defaultPolicy) {
- this.defaultPolicy = defaultPolicy;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof PolicyDefinition))
- return false;
- PolicyDefinition other = (PolicyDefinition) obj;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/RepositoryInformation.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/RepositoryInformation.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/RepositoryInformation.java
deleted file mode 100644
index 112117b..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/RepositoryInformation.java
+++ /dev/null
@@ -1,51 +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.manager.dto;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-public class RepositoryInformation implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String repoURL;
- private String[] refName;
-
- public String getRepoURL() {
- return repoURL;
- }
-
- public void setRepoURL(String repoURL) {
- this.repoURL = repoURL;
- }
-
- public String[] getRefName() {
- return refName;
- }
-
- public void setRefName(String[] refName) {
- if(refName == null) {
- this.refName = new String[0];
- } else {
- this.refName = Arrays.copyOf(refName, refName.length);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/SubscriptionInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/SubscriptionInfo.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/SubscriptionInfo.java
deleted file mode 100644
index cb83ee2..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/dto/SubscriptionInfo.java
+++ /dev/null
@@ -1,48 +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.manager.dto;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-
-@XmlRootElement
-public class SubscriptionInfo implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String hostname;
- private String repositoryURL;
-
- public String getHostname() {
- return hostname;
- }
-
- public void setHostname(String hostname) {
- this.hostname = hostname;
- }
-
- public String getRepositoryURL() {
- return repositoryURL;
- }
-
- public void setRepositoryURL(String repositoryURL) {
- this.repositoryURL = repositoryURL;
- }
-
-}
[08/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java
new file mode 100644
index 0000000..126c572
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/TenantEventPublisher.java
@@ -0,0 +1,124 @@
+/*
+ * 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.manager.messaging.publisher;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.beans.TenantInfoBean;
+import org.apache.stratos.common.exception.ApacheStratosException;
+import org.apache.stratos.common.listeners.TenantMgtListener;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.domain.tenant.Tenant;
+import org.apache.stratos.messaging.event.tenant.TenantCreatedEvent;
+import org.apache.stratos.messaging.event.tenant.TenantRemovedEvent;
+import org.apache.stratos.messaging.event.tenant.TenantUpdatedEvent;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * Tenant event publisher to publish tenant events to the message broker by
+ * listening to the tenant manager.
+ */
+public class TenantEventPublisher implements TenantMgtListener {
+
+ private static final Log log = LogFactory.getLog(TenantEventPublisher.class);
+ private static final int EXEC_ORDER = 1;
+
+ @Override
+ public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Publishing tenant created event: [tenant-id] %d [tenant-domain] %s",
+ tenantInfo.getTenantId(), tenantInfo.getTenantDomain()));
+ }
+ Tenant tenant = new Tenant(tenantInfo.getTenantId(), tenantInfo.getTenantDomain());
+ TenantCreatedEvent event = new TenantCreatedEvent(tenant);
+ String topic = Util.getMessageTopicName(event);
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
+ eventPublisher.publish(event);
+ } catch (Exception e) {
+ log.error(String.format("Could not publish tenant created event [tenant-id] %d [tenant-domain] %s ",
+ tenantInfo.getTenantId(),
+ tenantInfo.getTenantDomain()), e);
+ }
+ }
+
+ @Override
+ public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Publishing tenant updated event: [tenant-id] %d [tenant-domain] %s",
+ tenantInfo.getTenantId(), tenantInfo.getTenantDomain()));
+ }
+ TenantUpdatedEvent event =
+ new TenantUpdatedEvent(tenantInfo.getTenantId(),
+ tenantInfo.getTenantDomain());
+ String topic = Util.getMessageTopicName(event);
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
+ eventPublisher.publish(event);
+ } catch (Exception e) {
+ log.error(String.format("Could not publish tenant updated event:[tenant-id] %d [tenant-domain] %s ",
+ tenantInfo.getTenantId(),
+ tenantInfo.getTenantDomain()), e);
+ }
+ }
+
+ @Override
+ public void onTenantDelete(int tenantId) {
+ try {
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Publishing tenant removed event: [tenant-id] %d", tenantId));
+ }
+ TenantRemovedEvent event = new TenantRemovedEvent(tenantId);
+ String topic = Util.getMessageTopicName(event);
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
+ eventPublisher.publish(event);
+ } catch (Exception e) {
+ log.error(String.format("Could not publish tenant removed event [tenant-id] %d", tenantId),e);
+ }
+ }
+
+ @Override
+ public void onTenantRename(int tenantId, String oldDomainName, String newDomainName)
+ throws ApacheStratosException {
+ }
+
+ @Override
+ public void onTenantInitialActivation(int tenantId) throws ApacheStratosException {
+ }
+
+ @Override
+ public void onTenantActivation(int tenantId) throws ApacheStratosException {
+ }
+
+ @Override
+ public void onTenantDeactivation(int tenantId) throws ApacheStratosException {
+ }
+
+ @Override
+ public void onSubscriptionPlanChange(int tenantId, String oldPlan, String newPlan)
+ throws ApacheStratosException {
+ }
+
+ @Override
+ public int getListenerOrder() {
+ return EXEC_ORDER;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerInstanceStatusEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerInstanceStatusEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerInstanceStatusEventReceiver.java
new file mode 100644
index 0000000..3bc325c
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerInstanceStatusEventReceiver.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.manager.messaging.receiver;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
+import org.apache.stratos.autoscaler.stub.pojo.CartridgeContext;
+import org.apache.stratos.autoscaler.stub.pojo.SubscribableInfoContext;
+import org.apache.stratos.manager.client.AutoscalerServiceClient;
+import org.apache.stratos.manager.messaging.publisher.InstanceNotificationPublisher;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
+import org.apache.stratos.messaging.listener.instance.status.InstanceStartedEventListener;
+import org.apache.stratos.messaging.message.receiver.instance.status.InstanceStatusEventReceiver;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Stratos manager instance status event receiver.
+ */
+public class StratosManagerInstanceStatusEventReceiver extends InstanceStatusEventReceiver {
+
+ private static final Log log = LogFactory.getLog(StratosManagerInstanceStatusEventReceiver.class);
+
+ public StratosManagerInstanceStatusEventReceiver() {
+ addEventListeners();
+ }
+
+ private void addEventListeners() {
+ addEventListener(new InstanceStartedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+ InstanceStartedEvent instanceStartedEvent = (InstanceStartedEvent) event;
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Instance started event received: [application-id] %s [cartridge-type] %s " +
+ "[member-id] %s", instanceStartedEvent.getApplicationId(),
+ instanceStartedEvent.getServiceName(), instanceStartedEvent.getMemberId()));
+ }
+
+ try {
+ String applicationId = instanceStartedEvent.getApplicationId();
+ String serviceName = instanceStartedEvent.getServiceName();
+ String clusterId = instanceStartedEvent.getClusterId();
+
+ if (StringUtils.isBlank(applicationId)) {
+ throw new RuntimeException("Application id not found in instance started event: " + instanceStartedEvent);
+ }
+
+ if (StringUtils.isBlank(serviceName)) {
+ throw new RuntimeException("Service name not found in instance started event: " + instanceStartedEvent);
+ }
+
+ if (StringUtils.isBlank(clusterId)) {
+ throw new RuntimeException("Cluster id not found in instance started event: " + instanceStartedEvent);
+ }
+
+ AutoscalerServiceClient autoscalerServiceClient = AutoscalerServiceClient.getServiceClient();
+ ApplicationContext applicationContext = autoscalerServiceClient.getApplication(applicationId);
+ if (applicationContext == null) {
+ throw new RuntimeException("Application not found: [application-id] " + applicationId);
+ }
+
+ List<SubscribableInfoContext> subscribableInfoContexts = findCartridgeContext(applicationContext, serviceName);
+ if ((subscribableInfoContexts == null) || (subscribableInfoContexts.size() == 0)) {
+ throw new RuntimeException(String.format("Subscribable information not found: " +
+ "[application-id] %s [cartridge-type] %s", applicationId, serviceName));
+ }
+
+ InstanceNotificationPublisher publisher = new InstanceNotificationPublisher();
+
+ for(SubscribableInfoContext subscribableInfoContext : subscribableInfoContexts) {
+ String tenantId = "-1234";
+ publisher.publishArtifactUpdatedEvent(clusterId, tenantId, subscribableInfoContext.getRepoUrl(), subscribableInfoContext.getRepoUsername(),
+ subscribableInfoContext.getRepoPassword(), false);
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Artifact updated event published: [application-id] %s [cartridge-type] %s " +
+ "[member-id] %s [subscription-alias] %s [repo-url] %s",
+ instanceStartedEvent.getApplicationId(), instanceStartedEvent.getServiceName(),
+ instanceStartedEvent.getMemberId(), subscribableInfoContext.getAlias(),
+ subscribableInfoContext.getRepoUrl()));
+ }
+ }
+ } catch (Exception e) {
+ String message = "Could not send artifact updated event";
+ log.error(message, e);
+ }
+ }
+ });
+ }
+
+ /**
+ * Find subscribable info contexts of cartridge type/service name.
+ * @param applicationContext
+ * @param serviceName
+ * @return
+ */
+ private List<SubscribableInfoContext> findCartridgeContext(ApplicationContext applicationContext, String serviceName) {
+ List<SubscribableInfoContext> subscribableInfoContexts = new ArrayList<SubscribableInfoContext>();
+ CartridgeContext[] cartridgeContexts = applicationContext.getComponents().getCartridgeContexts();
+ if (cartridgeContexts != null) {
+ for (CartridgeContext cartridgeContext : cartridgeContexts) {
+ if (cartridgeContext != null) {
+ if (cartridgeContext.getType().equals(serviceName)) {
+ subscribableInfoContexts.add(cartridgeContext.getSubscribableInfoContext());
+ }
+ }
+ }
+ }
+ return subscribableInfoContexts;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerTopologyEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerTopologyEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerTopologyEventReceiver.java
new file mode 100644
index 0000000..b481e46
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/receiver/StratosManagerTopologyEventReceiver.java
@@ -0,0 +1,475 @@
+/*
+ * 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.manager.messaging.receiver;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.topology.Cluster;
+import org.apache.stratos.messaging.domain.topology.Service;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.topology.*;
+import org.apache.stratos.messaging.listener.topology.*;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver;
+import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
+
+import java.util.concurrent.ExecutorService;
+
+public class StratosManagerTopologyEventReceiver implements Runnable {
+
+ private static final Log log = LogFactory.getLog(StratosManagerTopologyEventReceiver.class);
+
+ private TopologyEventReceiver topologyEventReceiver;
+ private boolean terminated;
+ private ExecutorService executorService;
+
+ public StratosManagerTopologyEventReceiver() {
+ this.terminated = false;
+ this.topologyEventReceiver = new TopologyEventReceiver();
+ addEventListeners();
+ }
+
+ private void addEventListeners() {
+ //add listner to Complete Topology Event
+ topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+// if (TopologyClusterInformationModel.getInstance().isInitialized()) {
+// return;
+// }
+//
+// log.info("[CompleteTopologyEventListener] Received: " + event.getClass());
+//
+// try {
+// TopologyManager.acquireReadLock();
+//
+// for (Service service : TopologyManager.getTopology()
+// .getServices()) {
+// // iterate through all clusters
+// for (Cluster cluster : service.getClusters()) {
+// TopologyClusterInformationModel.getInstance()
+// .addCluster(cluster);
+// }
+// }
+//
+// TopologyClusterInformationModel.getInstance().setInitialized(true);
+//
+// } finally {
+// TopologyManager.releaseReadLock();
+// }
+ }
+ });
+
+ //Cluster Created event listner
+ topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("[ClusterCreatedEventListener] Received: " + event.getClass());
+
+// ClusterCreatedEvent clustercreatedEvent = (ClusterCreatedEvent) event;
+//
+// String serviceType = clustercreatedEvent.getCluster().getServiceName();
+// //acquire read lock
+// //TopologyManager.acquireReadLock();
+// TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
+// clustercreatedEvent.getCluster().getClusterId());
+//
+// try {
+// Cluster cluster = TopologyManager.getTopology().getService(serviceType).
+// getCluster(clustercreatedEvent.getCluster().getClusterId());
+// TopologyClusterInformationModel.getInstance().addCluster(cluster);
+//
+// } finally {
+// //release read lock
+// //TopologyManager.releaseReadLock();
+// TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(),
+// clustercreatedEvent.getCluster().getClusterId());
+// }
+
+ }
+ });
+
+
+ //Cluster Removed event listner
+ topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("[ClusterRemovedEventListener] Received: " + event.getClass());
+
+// ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event;
+// TopologyClusterInformationModel.getInstance().removeCluster(clusterRemovedEvent.getClusterId());
+ }
+ });
+
+
+ //Instance Spawned event listner
+ topologyEventReceiver.addEventListener(new MemberCreatedEventListener() {
+
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("Member created event received: " + event.getClass());
+
+// MemberCreatedEvent memberCreatedEvent = (MemberCreatedEvent) event;
+//
+// String clusterDomain = memberCreatedEvent.getClusterId();
+//
+// String serviceType = memberCreatedEvent.getServiceName();
+// //acquire read lock
+// //TopologyManager.acquireReadLock();
+// TopologyManager.acquireReadLockForCluster(memberCreatedEvent.getServiceName(),
+// memberCreatedEvent.getClusterId());
+//
+// try {
+// Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
+// TopologyClusterInformationModel.getInstance().addCluster(cluster);
+// } finally {
+// //release read lock
+// //TopologyManager.releaseReadLock();
+// TopologyManager.releaseReadLockForCluster(memberCreatedEvent.getServiceName(),
+// memberCreatedEvent.getClusterId());
+// }
+ }
+ });
+
+ //Member Started event listner
+ topologyEventReceiver.addEventListener(new MemberStartedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("[MemberStartedEventListener] Received: " + event.getClass());
+
+// MemberStartedEvent memberStartedEvent = (MemberStartedEvent) event;
+//
+// String clusterDomain = memberStartedEvent.getClusterId();
+//
+// String serviceType = memberStartedEvent.getServiceName();
+// //acquire read lock
+// //TopologyManager.acquireReadLock();
+// TopologyManager.acquireReadLockForCluster(memberStartedEvent.getServiceName(),
+// memberStartedEvent.getClusterId());
+//
+// try {
+// Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
+// TopologyClusterInformationModel.getInstance().addCluster(cluster);
+// } finally {
+// //release read lock
+// //TopologyManager.releaseReadLock();
+// TopologyManager.releaseReadLockForCluster(memberStartedEvent.getServiceName(),
+// memberStartedEvent.getClusterId());
+// }
+ }
+ });
+
+ //Member Activated event listner
+ topologyEventReceiver.addEventListener(new MemberActivatedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("[MemberActivatedEventListener] Received: " + event.getClass());
+
+// MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event;
+//
+// String clusterDomain = memberActivatedEvent.getClusterId();
+//
+// String serviceType = memberActivatedEvent.getServiceName();
+// //acquire read lock
+// //TopologyManager.acquireReadLock();
+// TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(),
+// memberActivatedEvent.getClusterId());
+//
+// try {
+// Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
+// TopologyClusterInformationModel.getInstance().addCluster(cluster);
+// } finally {
+// //release read lock
+// //TopologyManager.releaseReadLock();
+// TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(),
+// memberActivatedEvent.getClusterId());
+// }
+ }
+ });
+
+ // MemberReadyToShutdown
+ topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+ log.info("[MemberReadyToShutdownEventListener] Received: " + event.getClass());
+
+// MemberReadyToShutdownEvent memberReadyToShutdowEvent = (MemberReadyToShutdownEvent) event;
+//
+// String clusterDomain = memberReadyToShutdowEvent.getClusterId();
+//
+// String serviceType = memberReadyToShutdowEvent.getServiceName();
+// //acquire read lock
+// TopologyManager.acquireReadLock();
+//
+// try {
+// Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
+// TopologyClusterInformationModel.getInstance().addCluster(cluster);
+//
+// } finally {
+// //release read lock
+// TopologyManager.releaseReadLock();
+// }
+ }
+ });
+
+
+ //Member Suspended event listner
+ topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("[MemberSuspendedEventListener] Received: " + event.getClass());
+
+// MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event;
+//
+// String clusterDomain = memberSuspendedEvent.getClusterId();
+//
+// String serviceType = memberSuspendedEvent.getServiceName();
+// //acquire read lock
+// //TopologyManager.acquireReadLock();
+// TopologyManager.acquireReadLockForCluster(memberSuspendedEvent.getServiceName(),
+// memberSuspendedEvent.getClusterId());
+//
+// try {
+// Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
+// TopologyClusterInformationModel.getInstance().addCluster(cluster);
+//
+// } finally {
+// //release read lock
+// //TopologyManager.releaseReadLock();
+// TopologyManager.releaseReadLockForCluster(memberSuspendedEvent.getServiceName(),
+// memberSuspendedEvent.getClusterId());
+// }
+ }
+ });
+
+ //Member Terminated event listner
+ topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ log.info("[MemberTerminatedEventListener] Received: " + event.getClass());
+
+// MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event;
+//
+// String clusterDomain = memberTerminatedEvent.getClusterId();
+//
+// String serviceType = memberTerminatedEvent.getServiceName();
+// //acquire read lock
+// //TopologyManager.acquireReadLock();
+// TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(),
+// memberTerminatedEvent.getClusterId());
+//
+// try {
+// Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain);
+//
+// // check and remove terminated member
+//// if (cluster.memberExists(memberTerminatedEvent.getMemberId())) {
+//// // release the read lock and acquire the write lock
+////// TopologyManager.releaseReadLock();
+////// TopologyManager.acquireWriteLock();
+//// TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(),
+//// memberTerminatedEvent.getClusterId());
+//// TopologyManager.acquireWriteLockForCluster(memberTerminatedEvent.getServiceName(),
+//// memberTerminatedEvent.getClusterId());
+////
+//// try {
+//// // re-check the state; another thread might have acquired the write lock and modified
+//// if (cluster.memberExists(memberTerminatedEvent.getMemberId())) {
+//// // remove the member from the cluster
+//// Member terminatedMember = cluster.getMember(memberTerminatedEvent.getMemberId());
+//// cluster.removeMember(terminatedMember);
+//// if (log.isDebugEnabled()) {
+//// log.debug("Removed the terminated member with id " + memberTerminatedEvent.getMemberId() + " from the cluster");
+//// }
+//// }
+////
+//// // downgrade to read lock - 1. acquire read lock, 2. release write lock
+//// // acquire read lock
+//// //TopologyManager.acquireReadLock();
+//// TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(),
+//// memberTerminatedEvent.getClusterId());
+////
+//// } finally {
+//// // release the write lock
+//// // TopologyManager.releaseWriteLock();
+//// TopologyManager.releaseWriteLockForCluster(memberTerminatedEvent.getServiceName(),
+//// memberTerminatedEvent.getClusterId());
+//// }
+//// }
+// TopologyClusterInformationModel.getInstance().addCluster(cluster);
+// } finally {
+// //release read lock
+// //TopologyManager.releaseReadLock();
+// TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(),
+// memberTerminatedEvent.getClusterId());
+// }
+ }
+ });
+
+ //add listner to Complete Topology Event
+/*
+ topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ ApplicationCreatedEvent appCreateEvent = (ApplicationCreatedEvent) event;
+
+ log.info("[ApplicationCreatedEventListener] Received: " + event.getClass());
+
+ try {
+ //TopologyManager.acquireReadLock();
+ TopologyManager.acquireReadLockForApplication(appCreateEvent.getApplication().getUniqueIdentifier());
+
+ // create and persist Application subscritpion
+ CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager();
+ ApplicationSubscription compositeAppSubscription;
+ Application app = appCreateEvent.getApplication();
+ String appId = app.getUniqueIdentifier();
+ int tenantId = app.getTenantId();
+ String domain = app.getTenantDomain();
+
+ if (log.isDebugEnabled()) {
+ log.debug("received application created event for app: " + appId + " and tenant: " + tenantId +
+ " domain:" + domain);
+ }
+ try {
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ carbonContext.setTenantDomain(domain);
+ carbonContext.setTenantId(tenantId);
+ // create Application Subscription and persist
+ compositeAppSubscription = cartridgeSubscriptionManager.createApplicationSubscription(appId, tenantId);
+ cartridgeSubscriptionManager.persistApplicationSubscription(compositeAppSubscription);
+ } catch (ApplicationSubscriptionException e) {
+ log.error("failed to persist application subscription, caught exception: " + e);
+ } catch (ADCException e) {
+ log.error("failed to persist application subscription, caught exception: " + e);
+ } finally {
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+
+ // add the clusters to the topology information model
+ List<Cluster> appClusters = appCreateEvent.getClusterList();
+ if (appClusters != null && !appClusters.isEmpty()) {
+ for (Cluster appCluster : appClusters) {
+ TopologyClusterInformationModel.getInstance().addCluster(appCluster);
+ }
+ } else {
+ log.warn("No clusters were found in the Application Created event for app id [ " +
+ appId + " ] to add to Cluster Information model");
+ }
+
+ } finally {
+ //TopologyManager.releaseReadLock();
+ TopologyManager.releaseReadLockForApplication(appCreateEvent.getApplication().getUniqueIdentifier());
+ }
+ }
+ });
+*/
+
+ //add listener
+/*
+ topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() {
+ @Override
+ protected void onEvent(Event event) {
+
+ ApplicationTerminatedEvent appRemovedEvent = (ApplicationTerminatedEvent) event;
+
+ log.info("[ApplicationTerminatedEvent] Received: " + event.getClass());
+
+ try {
+ // no need to lock since Topology is not accessed
+ //TopologyManager.acquireReadLock();
+ //TopologyManager.acquireReadLockForApplication(appRemovedEvent.getAppId());
+
+ // create and persist Application subscritpion
+ CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager();
+ String appId = appRemovedEvent.getAppId();
+
+ int tenantId = appRemovedEvent.getTenantId();
+ String domain = appRemovedEvent.getTenantDomain();
+
+ if (log.isDebugEnabled()) {
+ log.debug("received application created event for app: " + appId + " and tenant: " + tenantId +
+ " domain:" + domain);
+ }
+ try {
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ carbonContext.setTenantDomain(domain);
+ carbonContext.setTenantId(tenantId);
+ // create Application Subscription and persist
+ cartridgeSubscriptionManager.removeApplicationSubscription(appId, tenantId);
+
+ } catch (ApplicationSubscriptionException e) {
+ log.error("failed to persist application subscription, caught exception: " + e);
+ } finally {
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+ } finally {
+ //TopologyManager.releaseReadLock();
+ //TopologyManager.releaseReadLockForApplication(appRemovedEvent.getAppId());
+ }
+ }
+ });
+*/
+ }
+
+
+ @Override
+ public void run() {
+
+ topologyEventReceiver.setExecutorService(executorService);
+ topologyEventReceiver.execute();
+ // executorService.execute(topologyEventReceiver);
+
+ log.info("Stratos Manager topology receiver thread started");
+
+ //Keep running till terminate is set from deactivate method of the component
+ while (!terminated) {
+ //loop while terminate = false
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignore) {
+ }
+ }
+ log.info("Stratos Manager topology receiver thread terminated");
+ }
+
+ //terminate Topology Receiver
+ public void terminate () {
+ topologyEventReceiver.terminate();
+ terminated = true;
+ }
+
+ public ExecutorService getExecutorService() {
+ return executorService;
+ }
+
+ public void setExecutorService(ExecutorService executorService) {
+ this.executorService = executorService;
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/ApplicationCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/ApplicationCartridgePayloadData.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/ApplicationCartridgePayloadData.java
deleted file mode 100644
index 5506427..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/ApplicationCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +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.manager.payload;
-
-public class ApplicationCartridgePayloadData extends PayloadData {
-
- public ApplicationCartridgePayloadData(BasicPayloadData basicPayloadData) {
- super(basicPayloadData);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/BasicPayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/BasicPayloadData.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/BasicPayloadData.java
deleted file mode 100644
index 234dac1..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/BasicPayloadData.java
+++ /dev/null
@@ -1,232 +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.manager.payload;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-import java.io.Serializable;
-
-/**
- * Contains basic payload data fields
- */
-public class BasicPayloadData implements Serializable {
-
- private static Log log = LogFactory.getLog(BasicPayloadData.class);
-
- private String serviceName;
- private String clusterId;
- private String hostName;
- private int tenantId;
- private String tenantRange;
- private String subscriptionAlias;
- private String deployment;
- private String puppetIp;
- private String puppetHostName;
- private String puppetEnvironment;
- private String subscriptionKey;
- private String applicationPath;
- private String gitRepositoryUrl;
- private String portMappings;
- private String multitenant;
- private String provider;
-
- protected StringBuilder payloadBuilder;
-
- public BasicPayloadData() {
-
- }
-
- public void populatePayload () {
-
- payloadBuilder = new StringBuilder();
-
- payloadBuilder.append("SERVICE_NAME=" + getServiceName());
- payloadBuilder.append(",");
- payloadBuilder.append("HOST_NAME=" + getHostName());
- payloadBuilder.append(",");
- payloadBuilder.append("MULTITENANT=" + getMultitenant());
- payloadBuilder.append(",");
- payloadBuilder.append("TENANT_ID=" + getTenantId());
- payloadBuilder.append(",");
- payloadBuilder.append("TENANT_RANGE=" + getTenantRange());
- payloadBuilder.append(",");
- payloadBuilder.append("CARTRIDGE_ALIAS=" + getSubscriptionAlias());
- payloadBuilder.append(",");
- payloadBuilder.append("CLUSTER_ID=" + getClusterId());
- payloadBuilder.append(",");
- payloadBuilder.append("CARTRIDGE_KEY=" + getSubscriptionKey());
- payloadBuilder.append(",");
- //payloadBuilder.append("DEPLOYMENT=" + getDeployment());
- //payloadBuilder.append(",");
- //payloadBuilder.append("APP_PATH=" + getApplicationPath());
- //payloadBuilder.append(",");
- payloadBuilder.append("REPO_URL=" + getGitRepositoryUrl());
- payloadBuilder.append(",");
- payloadBuilder.append("PORTS=" + getPortMappings());
- payloadBuilder.append(",");
- payloadBuilder.append("PROVIDER=" + getProvider());
-
- //Payload Data exposed as system variables
- payloadBuilder.append(",");
- payloadBuilder.append("PUPPET_IP=" + System.getProperty(CartridgeConstants.PUPPET_IP));
- payloadBuilder.append(",");
- payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty(CartridgeConstants.PUPPET_HOSTNAME));
- payloadBuilder.append(",");
- payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty(CartridgeConstants.PUPPET_DNS_AVAILABLE));
- payloadBuilder.append(",");
- payloadBuilder.append("PUPPET_ENV=" + System.getProperty(CartridgeConstants.PUPPET_ENVIRONMENT));
-
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- public String getClusterId() {
- return clusterId;
- }
-
- public void setClusterId(String clusterId) {
- this.clusterId = clusterId;
- }
-
- public String getHostName() {
- return hostName;
- }
-
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getTenantRange() {
- return tenantRange;
- }
-
- public void setTenantRange(String tenantRange) {
- this.tenantRange = tenantRange;
- }
-
- public String getSubscriptionAlias() {
- return subscriptionAlias;
- }
-
- public void setSubscriptionAlias(String subscriptionAlias) {
- this.subscriptionAlias = subscriptionAlias;
- }
-
- public String getDeployment() {
- return deployment;
- }
-
- public void setDeployment(String deployment) {
- this.deployment = deployment;
- }
-
- public String getPuppetIp() {
- return puppetIp;
- }
-
- public void setPuppetIp(String puppetIp) {
- this.puppetIp = puppetIp;
- }
-
- public String getSubscriptionKey() {
- return subscriptionKey;
- }
-
- public void setSubscriptionKey(String subscriptionKey) {
- this.subscriptionKey = subscriptionKey;
- }
-
- public StringBuilder getPayloadData () {
-
- return payloadBuilder;
- }
-
- public String getApplicationPath() {
- return applicationPath;
- }
-
- public void setApplicationPath(String applicationPath) {
- this.applicationPath = applicationPath;
- }
-
- public String getGitRepositoryUrl() {
- return gitRepositoryUrl;
- }
-
- public void setGitRepositoryUrl(String gitRepositoryUrl) {
- this.gitRepositoryUrl = gitRepositoryUrl;
- }
-
- public String getPortMappings() {
- return portMappings;
- }
-
- public void setPortMappings(String portMappings) {
- this.portMappings = portMappings;
- }
-
- public String getMultitenant() {
- return multitenant;
- }
-
- public void setMultitenant(String multitenant) {
- this.multitenant = multitenant;
- }
-
- public String getPuppetHostName() {
- return puppetHostName;
- }
-
- public void setPuppetHostName(String puppetHostName) {
- this.puppetHostName = puppetHostName;
- }
-
- public String getPuppetEnvironment() {
- return puppetEnvironment;
- }
-
- public void setPuppetEnvironment(String puppetEnvironment) {
- this.puppetEnvironment = puppetEnvironment;
- }
-
- public String getProvider() {
- return provider;
- }
-
- public void setProvider(String provider) {
- this.provider = provider;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/DataCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/DataCartridgePayloadData.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/DataCartridgePayloadData.java
deleted file mode 100644
index 2c71157..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/DataCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +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.manager.payload;
-
-public class DataCartridgePayloadData extends PayloadData {
-
- public DataCartridgePayloadData(BasicPayloadData basicPayloadData) {
- super(basicPayloadData);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/FrameworkCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/FrameworkCartridgePayloadData.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/FrameworkCartridgePayloadData.java
deleted file mode 100644
index a3d12bd..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/FrameworkCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +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.manager.payload;
-
-public class FrameworkCartridgePayloadData extends PayloadData {
-
- public FrameworkCartridgePayloadData(BasicPayloadData basicPayloadData) {
- super(basicPayloadData);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/LoadBalancerCartridgePayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/LoadBalancerCartridgePayloadData.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/LoadBalancerCartridgePayloadData.java
deleted file mode 100644
index 79e88c9..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/LoadBalancerCartridgePayloadData.java
+++ /dev/null
@@ -1,27 +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.manager.payload;
-
-public class LoadBalancerCartridgePayloadData extends PayloadData {
-
- public LoadBalancerCartridgePayloadData(BasicPayloadData basicPayloadData) {
- super(basicPayloadData);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadData.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadData.java
deleted file mode 100644
index aa38780..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadData.java
+++ /dev/null
@@ -1,69 +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.manager.payload;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public abstract class PayloadData implements Serializable {
-
- private BasicPayloadData basicPayloadData;
- private Map<String, String> completePayloadMap;
- public PayloadData(BasicPayloadData basicPayloadData) {
-
- this.setBasicPayloadData(basicPayloadData);
- completePayloadMap = new HashMap<String, String>();
- }
-
- public void add (String payloadDataName, String payloadDataValue) {
- completePayloadMap.put(payloadDataName, payloadDataValue);
- }
-
- public StringBuilder getCompletePayloadData () {
-
- //return completePayloadMap;
- StringBuilder completePayload = new StringBuilder();
- completePayload.append(basicPayloadData.getPayloadData());
- Iterator< String > iter = completePayloadMap.keySet().iterator();
- while(iter.hasNext()) {
- String key = iter.next();
- String val = completePayloadMap.get(key);
- if(completePayload.length() > 0){
- completePayload.append(",");
- }
- completePayload.append(key + "=" + val);
- }
- return completePayload;
- }
-
- public BasicPayloadData getBasicPayloadData() {
- return basicPayloadData;
- }
-
- public void setBasicPayloadData(BasicPayloadData basicPayloadData) {
- this.basicPayloadData = basicPayloadData;
- }
-
- public String toString () {
- return getCompletePayloadData().toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadFactory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadFactory.java
deleted file mode 100755
index 06ecbcf..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/payload/PayloadFactory.java
+++ /dev/null
@@ -1,60 +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.manager.payload;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-public class PayloadFactory {
-
- private static Log log = LogFactory.getLog(PayloadFactory.class);
-
- /**
- * Creates and returns a PayloadData instance
- *
- * @param cartridgeProvider Cartridge provider
- * @param cartridgeType Cartridge type
- * @param basicPayloadData BasicPayloadData instance
- * @return Payload subscription
- * @throws ADCException if no matching criteria is found to create a payload
- */
- public static PayloadData getPayloadDataInstance(String cartridgeProvider, String cartridgeType,
- BasicPayloadData basicPayloadData)
- throws ADCException {
-
- PayloadData payloadData = null;
-
- //TODO: fix after adding the property Category to Cartridge Definition
- if (cartridgeProvider.equals(CartridgeConstants.DATA_CARTRIDGE_PROVIDER)) {
- payloadData = new DataCartridgePayloadData(basicPayloadData);
- } else {
- payloadData = new FrameworkCartridgePayloadData(basicPayloadData);
- }
-
- if(payloadData == null) {
- throw new ADCException("Unable to find matching payload for cartridge type " + cartridgeType +
- ", provider " + cartridgeProvider);
- }
-
- return payloadData;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java
deleted file mode 100644
index b0dc792..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/PersistenceManager.java
+++ /dev/null
@@ -1,83 +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.manager.persistence;
-
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.ApplicationSubscription;
-import org.apache.stratos.manager.subscription.GroupSubscription;
-
-import java.util.Collection;
-
-public abstract class PersistenceManager {
-
- public abstract void persistCartridgeSubscription (CartridgeSubscription cartridgeSubscription)
- throws PersistenceManagerException;
-
- public abstract void persistGroupSubscription (GroupSubscription groupSubscription)
- throws PersistenceManagerException;
-
- public abstract GroupSubscription getGroupSubscription (int tenantId, String groupName, String groupAlias)
- throws PersistenceManagerException;
-
- public abstract void removeGroupSubscription (int tenantId, String groupName, String groupAlias)
- throws PersistenceManagerException;
-
- public abstract void removeCartridgeSubscription (int tenantId, String type, String alias)
- throws PersistenceManagerException;
-
- public abstract Collection<CartridgeSubscription> getCartridgeSubscriptions()
- throws PersistenceManagerException;
-
- public abstract Collection<CartridgeSubscription> getCartridgeSubscriptions(int tenantId)
- throws PersistenceManagerException;
-
- public abstract void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription)
- throws PersistenceManagerException;
-
- public abstract ApplicationSubscription getCompositeAppSubscription (int tenantId, String compositeAppId)
- throws PersistenceManagerException;
-
- public abstract void removeCompositeAppSubscription (int tenantId, String compositeAppId)
- throws PersistenceManagerException;
-
- public abstract void persistService (Service service) throws PersistenceManagerException;
-
- public abstract Collection<Service> getServices () throws PersistenceManagerException;
-
- public abstract Service getService (String cartridgeType) throws PersistenceManagerException;
-
- public abstract void removeService (String cartridgeType) throws PersistenceManagerException;
-
- public abstract void persistServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException;
-
- public abstract ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException;
-
- public abstract void removeServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException;
-
- public abstract void createApplication (ApplicationDefinition appDefinition) throws PersistenceManagerException;
-
- public abstract ApplicationDefinition getApplication (String appId) throws PersistenceManagerException;
-
- public abstract void removeApplication (String appId) throws PersistenceManagerException;
-}
[03/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepositoryCreator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepositoryCreator.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepositoryCreator.java
deleted file mode 100644
index c6406f1..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/RepositoryCreator.java
+++ /dev/null
@@ -1,295 +0,0 @@
-package org.apache.stratos.manager.utils;
-/*
- *
- * 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.
- *
-*/
-
-
-import com.gitblit.Constants;
-import com.gitblit.models.RepositoryModel;
-import com.gitblit.utils.RpcUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.service.RepositoryInfoBean;
-import org.eclipse.jgit.api.*;
-import org.eclipse.jgit.storage.file.FileRepository;
-import org.eclipse.jgit.transport.CredentialsProvider;
-import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.UUID;
-
-public class RepositoryCreator implements Runnable {
-
- private static final Log log = LogFactory.getLog(RepositoryCreator.class);
- private RepositoryInfoBean repoInfoBean;
-
- public RepositoryCreator(RepositoryInfoBean repoInfoBean) {
- this.repoInfoBean = repoInfoBean;
- }
-
- @Override
- public void run() {
-
- if (repoInfoBean != null) {
- try {
- createRepository(repoInfoBean.getCartridgeAlias(), repoInfoBean.getTenantDomain(),
- repoInfoBean.getUserName(), repoInfoBean.getPassword());
- createGitFolderStructure(repoInfoBean.getTenantDomain(),
- repoInfoBean.getCartridgeAlias(),
- repoInfoBean.getDirArray());
-
- } catch (Exception e) {
- log.error(e);
- }
- }
- }
-
- //Creating the internal repo in the same thread as createSubscription()
- public Repository createInternalRepository () throws Exception {
-
- Repository repo = null;
-
- if (repoInfoBean != null) {
- try {
- repo = createRepository(repoInfoBean.getCartridgeAlias(), repoInfoBean.getTenantDomain(),
- repoInfoBean.getUserName(), repoInfoBean.getPassword());
-
- if (repoInfoBean.getDirArray() != null && repoInfoBean.getDirArray().length > 0) {
- createGitFolderStructure(repoInfoBean.getTenantDomain(),
- repoInfoBean.getCartridgeAlias(),
- repoInfoBean.getDirArray());
- }
-
- } catch (Exception e) {
- String errorMsg = "Creating an internal repository failed for tenant " + repoInfoBean.getTenantDomain();
- log.error(errorMsg, e);
- throw new Exception(errorMsg, e);
- }
- }
- return repo;
- }
-
- private Repository createRepository(String cartridgeName, String tenantDomain, String userName, String password)
- throws Exception {
-
- Repository repository = new Repository();
- String repoName = tenantDomain + "/" + cartridgeName;
-
- try {
-
- log.info("Creating internal repo ["+repoName+"] ");
-
- RepositoryModel model = new RepositoryModel();
- model.name = repoName;
- model.accessRestriction = Constants.AccessRestrictionType.VIEW;
-
- char[] passwordArr = password.toCharArray();
-
- boolean isSuccess =
- RpcUtils.createRepository(model,
- System.getProperty(CartridgeConstants.INTERNAL_GIT_URL),
- userName, passwordArr);
- if (!isSuccess) {
- throw new Exception("Exception is occurred when creating an internal git repo. ");
- }
- } catch (Exception e) {
- log.error(" Exception is occurred when creating an internal git repo. Reason :" +
- e.getMessage());
- handleException(e.getMessage(), e);
- }
-
- repository.setUrl(System.getProperty(CartridgeConstants.INTERNAL_GIT_URL) + "/git/" + repoName);
- repository.setUserName(userName);
- repository.setPassword(password);
-
- log.info("Repository is created. : " + repository);
- return repository;
-
- }
-
- private void createGitFolderStructure(String tenantDomain, String cartridgeName,
- String[] dirArray) throws Exception {
-
- if (log.isDebugEnabled()) {
- log.debug("Creating git repo folder structure ");
- }
-
- String parentDirName = "/tmp/" + UUID.randomUUID().toString();
- CredentialsProvider credentialsProvider =
- new UsernamePasswordCredentialsProvider(
- System.getProperty(CartridgeConstants.INTERNAL_GIT_USERNAME),
- System.getProperty(CartridgeConstants.INTERNAL_GIT_PASSWORD).toCharArray());
- // Clone
- // --------------------------
- FileRepository localRepo = null;
- try {
- localRepo = new FileRepository(new File(parentDirName + "/.git"));
- } catch (IOException e) {
- log.error("Exception occurred in creating a new file repository. Reason: " + e.getMessage());
- throw e;
- }
-
- Git git = new Git(localRepo);
-
- CloneCommand cloneCmd =
- git.cloneRepository()
- .setURI(System.getProperty(CartridgeConstants.INTERNAL_GIT_URL) +
- "/git/" + tenantDomain + "/" +
- cartridgeName + ".git")
- .setDirectory(new File(parentDirName));
-
- cloneCmd.setCredentialsProvider(credentialsProvider);
- try {
- log.debug("Clonning git repo");
- cloneCmd.call();
- } catch (Exception e1) {
- log.error("Exception occurred in cloning Repo. Reason: " + e1.getMessage());
- throw e1;
- }
- // ------------------------------------
-
- // --- Adding directory structure --------
-
- File parentDir = new File(parentDirName);
- parentDir.mkdir();
-
- for (String string : dirArray) {
- String[] arr = string.split("=");
- if (log.isDebugEnabled()) {
- log.debug("Creating dir: " + arr[0]);
- }
- File parentFile = new File(parentDirName + "/" + arr[0]);
- parentFile.mkdirs();
-
- File filess = new File(parentFile, "README");
- String content = "Content goes here";
-
- filess.createNewFile();
- FileWriter fw = new FileWriter(filess.getAbsoluteFile());
- BufferedWriter bw = new BufferedWriter(fw);
- bw.write(content);
- bw.close();
- }
- // ----------------------------------------------------------
-
- // ---- Git status ---------------
- StatusCommand s = git.status();
- Status status = null;
- try {
- log.debug("Getting git repo status");
- status = s.call();
- } catch (Exception e) {
- log.error("Exception occurred in git status check. Reason: " + e.getMessage());
- throw e;
- }
- // --------------------------------
-
- // ---------- Git add ---------------
- AddCommand addCmd = git.add();
- Iterator<String> it = status.getUntracked().iterator();
-
- while (it.hasNext()) {
- addCmd.addFilepattern(it.next());
- }
-
- try {
- log.debug("Adding files to git repo");
- addCmd.call();
- } catch (Exception e) {
- log.error("Exception occurred in adding files. Reason: " + e.getMessage());
- throw e;
- }
- // -----------------------------------------
-
- // ------- Git commit -----------------------
-
- CommitCommand commitCmd = git.commit();
- commitCmd.setMessage("Adding directories");
-
- try {
- log.debug("Committing git repo");
- commitCmd.call();
- } catch (Exception e) {
- log.error("Exception occurred in committing . Reason: " + e.getMessage());
- throw e;
- }
- // --------------------------------------------
-
- // --------- Git push -----------------------
- PushCommand pushCmd = git.push();
- pushCmd.setCredentialsProvider(credentialsProvider);
- try {
- log.debug("Git repo push");
- pushCmd.call();
- } catch (Exception e) {
- log.error("Exception occurred in Git push . Reason: " + e.getMessage());
- throw e;
- }
-
- try {
- deleteDirectory(new File(parentDirName));
- } catch (Exception e) {
- log.error("Exception occurred in deleting temp files. Reason: " + e.getMessage());
- throw e;
- }
-
- log.info(" Folder structure is created ..... ");
-
- }
-
- private void handleException(String msg, Exception e) throws Exception {
- log.error(msg, e);
- throw new Exception(msg, e);
- }
-
- private void deleteDirectory(File file) throws IOException {
-
- if (file.isDirectory()) {
- // directory is empty, then delete it
- if (file.list().length == 0) {
- file.delete();
-
- } else {
- // list all the directory contents
- String files[] = file.list();
-
- for (String temp : files) {
- // construct the file structure
- File fileDelete = new File(file, temp);
- // recursive delete
- deleteDirectory(fileDelete);
- }
- // check the directory again, if empty then delete it
- if (file.list().length == 0) {
- file.delete();
- }
- }
-
- } else {
- // if file, then delete it
- file.delete();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java
deleted file mode 100644
index 796bddc..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/Serializer.java
+++ /dev/null
@@ -1,160 +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.manager.utils;
-
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.lookup.ClusterIdToSubscription;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.ApplicationSubscription;
-import org.apache.stratos.manager.subscription.GroupSubscription;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-
-public class Serializer {
-
- /**
- * Serialize a SubscriptionContext instance to a byte array.
- * @param cartridgeSubscription
- * @return byte[]
- * @throws java.io.IOException
- */
- public static byte[] serializeSubscriptionSontextToByteArray(CartridgeSubscription cartridgeSubscription)
- throws IOException {
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(cartridgeSubscription);
-
- return bos.toByteArray();
-
- } finally {
- if (out != null) {
- out.close();
- }
- bos.close();
- }
-
- }
-
- public static byte[] serializeGroupSubscriptionToByteArray (GroupSubscription groupSubscription)
- throws IOException {
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(groupSubscription);
-
- return bos.toByteArray();
-
- } finally {
- if (out != null) {
- out.close();
- }
- bos.close();
- }
-
- }
-
- public static byte[] serializeCompositeAppSubscriptionToByteArray (ApplicationSubscription compositeAppSubscription)
- throws IOException {
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(compositeAppSubscription);
-
- return bos.toByteArray();
-
- } finally {
- if (out != null) {
- out.close();
- }
- bos.close();
- }
-
- }
-
- public static byte[] serializeServiceToByteArray(Service service)
- throws IOException {
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(service);
-
- return bos.toByteArray();
-
- } finally {
- if (out != null) {
- out.close();
- }
- bos.close();
- }
-
- }
-
- public static byte [] serializeServiceGroupDefinitionToByteArray (ServiceGroupDefinition serviceGroupDefinition)
- throws IOException {
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(serviceGroupDefinition);
-
- return bos.toByteArray();
-
- } finally {
- if (out != null) {
- out.close();
- }
- bos.close();
- }
- }
-
- public static byte [] serializeApplicationDefinitionToByteArray (ApplicationDefinition applicationDefinition)
- throws IOException {
-
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutput out = null;
- try {
- out = new ObjectOutputStream(bos);
- out.writeObject(applicationDefinition);
-
- return bos.toByteArray();
-
- } finally {
- if (out != null) {
- out.close();
- }
- bos.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/SynchronizeRepositoryRequest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/SynchronizeRepositoryRequest.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/SynchronizeRepositoryRequest.java
deleted file mode 100644
index 4c9f4e8..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/SynchronizeRepositoryRequest.java
+++ /dev/null
@@ -1,138 +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.manager.utils;
-
-import org.apache.axis2.clustering.ClusteringCommand;
-import org.apache.axis2.clustering.ClusteringFault;
-import org.apache.axis2.clustering.management.GroupManagementCommand;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.engine.AxisConfigurator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.core.CarbonAxisConfigurator;
-import org.wso2.carbon.core.multitenancy.TenantAxisConfigurator;
-import org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.util.UUID;
-
-/**
- * ClusterMessage for sending a deployment repository synchronization request
- */
-public class SynchronizeRepositoryRequest extends GroupManagementCommand {
-
- /**
- *
- */
- private static final long serialVersionUID = 8717694086109561127L;
-
- private transient static final Log log = LogFactory.getLog(SynchronizeRepositoryRequest.class);
- private int tenantId;
- private String tenantDomain;
- private UUID messageId;
-
- public SynchronizeRepositoryRequest() {
- }
-
- public SynchronizeRepositoryRequest(int tenantId, String tenantDomain, UUID messageId) {
- this.tenantId = tenantId;
- this.tenantDomain = tenantDomain;
- this.messageId = messageId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public void execute(ConfigurationContext configContext) throws ClusteringFault {
- log.info("Received [" + this + "] ");
- // Run only if the tenant is loaded
- if (tenantId == MultitenantConstants.SUPER_TENANT_ID ||
- TenantAxisUtils.getTenantConfigurationContexts(configContext).get(tenantDomain) != null) {
- updateDeploymentRepository(configContext);
- doDeployment(configContext);
- }
- }
-
- private void doDeployment(ConfigurationContext configContext) {
- AxisConfigurator axisConfigurator = configContext.getAxisConfiguration().getConfigurator();
- if (axisConfigurator instanceof CarbonAxisConfigurator) {
- ((CarbonAxisConfigurator) axisConfigurator).runDeployment();
- } else if (axisConfigurator instanceof TenantAxisConfigurator) {
- ((TenantAxisConfigurator) axisConfigurator).runDeployment();
- }
- }
-
- private void updateDeploymentRepository(ConfigurationContext configContext) {
-
- log.info(" Update Deployment Repo...");
- /*
- * BundleContext bundleContext =
- * CarbonCoreDataHolder.getInstance().getBundleContext();
- * ServiceReference reference =
- * bundleContext.getServiceReference(DeploymentSynchronizer.class.getName
- * ());
- * if (reference != null) {
- * ServiceTracker serviceTracker =
- * new ServiceTracker(bundleContext,
- * DeploymentSynchronizer.class.getName(), null);
- * try {
- * serviceTracker.open();
- * for (Object obj : serviceTracker.getServices()) {
- * // if the update is for worker node with ghost ON, then we will
- * update the
- * // whole repo for now. See CARBON-13899
- * if (GhostDeployerUtils.isGhostOn() && CarbonUtils.isWorkerNode() &&
- * tenantId > 0) {
- * String repoPath = MultitenantUtils.getAxis2RepositoryPath(tenantId);
- * ((DeploymentSynchronizer) obj).update(repoPath, repoPath, 3);
- * } else {
- * ((DeploymentSynchronizer) obj).update(tenantId);
- * }
- * }
- * } catch (Exception e) {
- * log.error("Repository update failed for tenant " + tenantId, e);
- * setRepoUpdateFailed(configContext);
- * } finally {
- * serviceTracker.close();
- * }
- * }
- */
- }
-
- private void setRepoUpdateFailed(ConfigurationContext configContext) {
- AxisConfigurator axisConfigurator = configContext.getAxisConfiguration().getConfigurator();
- if (axisConfigurator instanceof CarbonAxisConfigurator) {
- ((CarbonAxisConfigurator) axisConfigurator).setRepoUpdateFailed();
- } else if (axisConfigurator instanceof TenantAxisConfigurator) {
- ((TenantAxisConfigurator) axisConfigurator).setRepoUpdateFailed();
- }
- }
-
- public ClusteringCommand getResponse() {
- return null;
- }
-
- @Override
- public String toString() {
- return "SynchronizeRepositoryRequest{" + "tenantId=" + tenantId + ", tenantDomain='" +
- tenantDomain + '\'' + ", messageId=" + messageId + '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
index 4170efd..943af25 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/utils/UserRoleCreator.java
@@ -22,7 +22,7 @@ package org.apache.stratos.manager.utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
+import org.apache.stratos.manager.user.management.exception.UserManagerException;
import org.wso2.carbon.user.api.Permission;
import org.wso2.carbon.user.api.UserStoreException;
import org.wso2.carbon.user.api.UserStoreManager;
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/resources/META-INF/services.xml b/components/org.apache.stratos.manager/src/main/resources/META-INF/services.xml
index 46656af..d7e3c7c 100644
--- a/components/org.apache.stratos.manager/src/main/resources/META-INF/services.xml
+++ b/components/org.apache.stratos.manager/src/main/resources/META-INF/services.xml
@@ -17,23 +17,4 @@
# under the License.
-->
<serviceGroup>
-
- <service name="InstanceCleanupNotificationService" scope="transportsession">
- <schema schemaNamespace="http://org.apache.axis2/xsd"
- elementFormDefaultQualified="true" />
- <transports>
- <transport>https</transport>
- </transports>
- <description>
- Instance cleanup notification
- </description>
- <parameter name="ServiceClass">org.apache.stratos.manager.service.InstanceCleanupNotificationService</parameter>
- <parameter name="enableMTOM">true</parameter>
- <parameter name="adminService" locked="true">false</parameter>
- <parameter name="hiddenService" locked="true">false</parameter>
- <parameter name="AuthorizationAction" locked="false">
- /permission/admin/manage/modify/webapp
- </parameter>
- </service>
-
</serviceGroup>
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/CartridgeSubscriptionTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/CartridgeSubscriptionTest.java b/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/CartridgeSubscriptionTest.java
deleted file mode 100644
index 4528d2f..0000000
--- a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/CartridgeSubscriptionTest.java
+++ /dev/null
@@ -1,97 +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.manager.test;
-
-import junit.framework.TestCase;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionMultiTenantBehaviour;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionSingleTenantBehaviour;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-
-public class CartridgeSubscriptionTest extends TestCase {
-
- private CartridgeSubscription getCartridgeInstance (CartridgeInfo cartridgeInfo) {
-
- SubscriptionTenancyBehaviour tenancyBehaviour;
- if(cartridgeInfo.getMultiTenant()) {
- tenancyBehaviour = new SubscriptionMultiTenantBehaviour();
- } else {
- tenancyBehaviour = new SubscriptionSingleTenantBehaviour();
- }
-
- try {
- return CartridgeSubscriptionFactory.getCartridgeSubscriptionInstance(cartridgeInfo, tenancyBehaviour);
-
- } catch (ADCException e) {
- throw new RuntimeException(e);
- }
- }
-
- public void testCarbonCartridgeSubscription() {
-
- CartridgeInfo cartridgeInfo1 = new CartridgeInfo();
- cartridgeInfo1.setProvider("carbon");
- cartridgeInfo1.setMultiTenant(true);
- cartridgeInfo1.setType("esb");
- CartridgeSubscription cartridgeSubscription1 = getCartridgeInstance(cartridgeInfo1);
- assertNotNull(cartridgeSubscription1);
-
-
- CartridgeInfo cartridgeInfo2 = new CartridgeInfo();
- cartridgeInfo2.setProvider("carbon");
- cartridgeInfo2.setMultiTenant(false);
- cartridgeInfo2.setType("as");
- CartridgeSubscription cartridgeSubscription2 = getCartridgeInstance(cartridgeInfo2);
- assertNotNull(cartridgeSubscription2);
- }
-
- public void testPhpCartridgeSubscription() {
-
- CartridgeInfo cartridgeInfo = new CartridgeInfo();
- cartridgeInfo.setProvider("php-provider");
- cartridgeInfo.setMultiTenant(false);
- cartridgeInfo.setType("php");
- CartridgeSubscription cartridgeSubscription = getCartridgeInstance(cartridgeInfo);
- assertNotNull(cartridgeSubscription);
- }
-
- public void testMySqlCartridgeSubscription() {
-
- CartridgeInfo cartridgeInfo = new CartridgeInfo();
- cartridgeInfo.setProvider("data");
- cartridgeInfo.setMultiTenant(false);
- cartridgeInfo.setType("mysql");
- CartridgeSubscription cartridgeSubscription = getCartridgeInstance(cartridgeInfo);
- assertNotNull(cartridgeSubscription);
- }
-
- public void testTomcatCartridgeSubscription() {
-
- CartridgeInfo cartridgeInfo = new CartridgeInfo();
- cartridgeInfo.setProvider("tomcat-provider");
- cartridgeInfo.setMultiTenant(false);
- cartridgeInfo.setType("tomcat");
- CartridgeSubscription cartridgeSubscription = getCartridgeInstance(cartridgeInfo);
- assertNotNull(cartridgeSubscription);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/LookupDataHolderTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/LookupDataHolderTest.java b/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/LookupDataHolderTest.java
deleted file mode 100644
index 7147f20..0000000
--- a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/LookupDataHolderTest.java
+++ /dev/null
@@ -1,282 +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.manager.test;
-
-import junit.framework.TestCase;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionMultiTenantBehaviour;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionSingleTenantBehaviour;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.junit.Before;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class LookupDataHolderTest extends TestCase {
-
- Collection<CartridgeSubscription> cartridgeSubscriptions ;
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager;
-
- @Before
- public void setUp () {
- cartridgeSubscriptions = new ArrayList<CartridgeSubscription>();
- dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-
- setUpCsrtridgeSubscriptions();
- }
-
- private void setUpCsrtridgeSubscriptions() {
-
- CartridgeInfo cartridgeInfo1 = getCartridgeInfo("carbon", "esb", true);
- CartridgeSubscription cartridgeSubscription1 = getCartridgeInstance(cartridgeInfo1);
- assertNotNull(cartridgeSubscription1);
- Subscriber subscriber1 = getSubscriber("admin", 1, "a.com");
- cartridgeSubscription1.setSubscriber(subscriber1);
- cartridgeSubscription1.setClusterDomain("esb.domain");
- cartridgeSubscription1.setAlias("esba");
- cartridgeSubscriptions.add(cartridgeSubscription1);
-
- CartridgeInfo cartridgeInfo2 = getCartridgeInfo("carbon", "esb", true);
- CartridgeSubscription cartridgeSubscription2 = getCartridgeInstance(cartridgeInfo2);
- assertNotNull(cartridgeSubscription2);
- Subscriber subscriber2 = getSubscriber("admin", 2, "b.com");
- cartridgeSubscription2.setSubscriber(subscriber2);
- cartridgeSubscription2.setClusterDomain("esb.domain");
- cartridgeSubscription2.setAlias("esbb");
- cartridgeSubscriptions.add(cartridgeSubscription2);
-
- CartridgeInfo cartridgeInfo3 = getCartridgeInfo("carbon", "esb.privatejet", false);
- CartridgeSubscription cartridgeSubscription3 = getCartridgeInstance(cartridgeInfo3);
- assertNotNull(cartridgeSubscription3);
- Subscriber subscriber3 = getSubscriber("admin", 1, "a.com");
- cartridgeSubscription3.setSubscriber(subscriber3);
- cartridgeSubscription3.setClusterDomain("a.esb.domain");
- cartridgeSubscription3.setAlias("esba1");
- cartridgeSubscriptions.add(cartridgeSubscription3);
-
- CartridgeInfo cartridgeInfo4 = getCartridgeInfo("php-provider", "php", false);
- CartridgeSubscription cartridgeSubscription4 = getCartridgeInstance(cartridgeInfo4);
- assertNotNull(cartridgeSubscription4);
- Subscriber subscriber4 = getSubscriber("admin", 3, "c.com");
- cartridgeSubscription4.setSubscriber(subscriber4);
- cartridgeSubscription4.setClusterDomain("a.php.domain");
- cartridgeSubscription4.setAlias("phpa");
- cartridgeSubscriptions.add(cartridgeSubscription4);
-
- CartridgeInfo cartridgeInfo5 = getCartridgeInfo("mysql-provider", "mysql", false);
- CartridgeSubscription cartridgeSubscription5 = getCartridgeInstance(cartridgeInfo5);
- assertNotNull(cartridgeSubscription5);
- Subscriber subscriber5 = getSubscriber("admin", 3, "c.com");
- cartridgeSubscription5.setSubscriber(subscriber5);
- cartridgeSubscription5.setClusterDomain("a.mysql.domain");
- cartridgeSubscription5.setAlias("mysqla");
- cartridgeSubscriptions.add(cartridgeSubscription5);
-
- dataInsertionAndRetrievalManager.cacheSubscriptionsWithoutPersisting(cartridgeSubscriptions);
- }
-
- private CartridgeInfo getCartridgeInfo (String provider, String type, boolean multitenant) {
-
- CartridgeInfo cartridgeInfo = new CartridgeInfo();
- cartridgeInfo.setProvider(provider);
- cartridgeInfo.setType(type);
- cartridgeInfo.setMultiTenant(multitenant);
- return cartridgeInfo;
- }
-
- private Subscriber getSubscriber (String adminUser, int tenantId, String tenantDomain) {
- return new Subscriber(adminUser, tenantId, tenantDomain);
- }
-
- private CartridgeSubscription getCartridgeInstance (CartridgeInfo cartridgeInfo) {
-
- SubscriptionTenancyBehaviour tenancyBehaviour;
- if(cartridgeInfo.getMultiTenant()) {
- tenancyBehaviour = new SubscriptionMultiTenantBehaviour();
- } else {
- tenancyBehaviour = new SubscriptionSingleTenantBehaviour();
- }
-
- try {
- return CartridgeSubscriptionFactory.getCartridgeSubscriptionInstance(cartridgeInfo, tenancyBehaviour);
-
- } catch (ADCException e) {
- throw new RuntimeException(e);
- }
- }
-
- public void testClusterIdToSubscription () throws PersistenceManagerException {
-
- // check for tenant 1
- Collection<CartridgeSubscription> cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(1);
- assertEquals(2, cartridgeSubscriptions.size());
-
- // check for tenant 2
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(2);
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for tenant 3
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(3);
- assertEquals(2, cartridgeSubscriptions.size());
-
- // check for type 'esb'
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions("esb");
- assertEquals(2, cartridgeSubscriptions.size());
-
- // check for type 'esb.privatejet'
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions("esb.privatejet");
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for type 'php'
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions("php");
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for type 'mysql'
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions("mysql");
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for type 'esb' and tenant 1
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(1, "esb");
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for type 'esb' and tenant 2
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(2, "esb");
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for type 'esb.privatejet' and tenant 1
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(1, "esb.privatejet");
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for type 'esb.privatejet' and tenant 2
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(2, "esb.privatejet");
- assertNull(cartridgeSubscriptions);
-
- // check for type 'php' and tenant 1
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(1, "php");
- assertNull(cartridgeSubscriptions);
-
- // check for type 'mysql' and tenant 3
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptions(3, "mysql");
- assertEquals(1, cartridgeSubscriptions.size());
-
- // check for tenant 1 and alias 'esba'
- CartridgeSubscription subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esba");
- assertNotNull(subscription);
-
- // check for tenant 1 and alias 'esbb'
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esbb");
- assertNull(subscription);
-
- // check for tenant 2 and alias 'esba'
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esba");
- assertNull(subscription);
-
- // check for tenant 2 and alias 'esbb'
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esbb");
- assertNotNull(subscription);
-
- // check for tenant 1 and alias 'esba1'
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esba1");
- assertNotNull(subscription);
-
- // check for tenant 2 and alias 'esba1'
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esba1");
- assertNull(subscription);
-
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("esb.domain");
- assertNotNull(cartridgeSubscriptions);
- assertEquals(2, cartridgeSubscriptions.size());
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- assertTrue(cartridgeSubscription.getAlias().equals("esba") || cartridgeSubscription.getAlias().equals("esbb"));
- }
-
- dataInsertionAndRetrievalManager.removeSubscriptionFromCache(1, "esba");
-
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("esb.domain");
- assertNotNull(cartridgeSubscriptions);
- assertEquals(1, cartridgeSubscriptions.size());
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- assertTrue(cartridgeSubscription.getAlias().equals("esbb"));
- }
-
- dataInsertionAndRetrievalManager.removeSubscriptionFromCache(2, "esbb");
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("esb.domain"));
-
- cartridgeSubscriptions = dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("a.esb.domain");
- assertNotNull(cartridgeSubscriptions);
- assertEquals(1, cartridgeSubscriptions.size());
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- assertTrue(cartridgeSubscription.getAlias().equals("esba1"));
- }
-
- dataInsertionAndRetrievalManager.removeSubscriptionFromCache(1, "esba1");
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("a.esb.domain"));
-
- // check for tenant 3 and alias 'phpa'
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "phpa");
- assertNotNull(subscription);
- assertTrue(subscription.getAlias().equals("phpa"));
-
- dataInsertionAndRetrievalManager.removeSubscriptionFromCache(3, "phpa");
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "phpa");
- assertNull(subscription);
-
- // check for tenant 3 and alias 'mysqla'
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "mysqla");
- assertNotNull(subscription);
- assertTrue(subscription.getAlias().equals("mysqla"));
-
- dataInsertionAndRetrievalManager.removeSubscriptionFromCache(3, "mysqla");
- subscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "mysqla");
- assertNull(subscription);
-
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptions(1));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptions(2));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptions(3));
-
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("esb.domain"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("a.esb.domain"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("a.php.domain"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptionForCluster("a.mysql.domain"));
-
- assertTrue(dataInsertionAndRetrievalManager.getCartridgeSubscriptions("esb").isEmpty());
- assertTrue(dataInsertionAndRetrievalManager.getCartridgeSubscriptions("esb.privatejet").isEmpty());
- assertTrue(dataInsertionAndRetrievalManager.getCartridgeSubscriptions("php").isEmpty());
- assertTrue(dataInsertionAndRetrievalManager.getCartridgeSubscriptions("mysql").isEmpty());
-
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptions(1, "esb"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptions(1, "esb.privatejet"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptions(3, "php"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscriptions(3, "mysql"));
-
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esba"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esba"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscription(1, "esba1"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscription(2, "esbb"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "phpa"));
- assertNull(dataInsertionAndRetrievalManager.getCartridgeSubscription(3, "mysqla"));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PayloadTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PayloadTest.java b/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PayloadTest.java
deleted file mode 100644
index 07d05e7..0000000
--- a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PayloadTest.java
+++ /dev/null
@@ -1,196 +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.manager.test;
-//
-//import junit.framework.TestCase;
-//
-//import org.apache.stratos.manager.dto.Policy;
-//import org.apache.stratos.manager.exception.ADCException;
-//import org.apache.stratos.manager.payload.Payload;
-//import org.apache.stratos.manager.payload.PayloadArg;
-//import org.apache.stratos.manager.payload.PayloadFactory;
-//import org.apache.stratos.manager.utils.CartridgeConstants;
-//import org.apache.stratos.cloud.controller.pojo.CartridgeInfo;
-//import org.apache.stratos.cloud.controller.pojo.PortMapping;
-//
-//import java.math.BigDecimal;
-//
-//public class PayloadTest extends TestCase {
-//
-// protected void setUp() throws java.lang.Exception {
-//
-// System.setProperty(CartridgeConstants.REPO_INFO_EPR, "https://sm.stratos.com:9445/repository_info_service");
-// System.setProperty(CartridgeConstants.CARTRIDGE_AGENT_EPR, "https://sm.stratos.com:9445/cartridge_agent_service");
-// System.setProperty(CartridgeConstants.BAM_IP, "10.10.10.10");
-// System.setProperty(CartridgeConstants.BAM_PORT, "7714");
-// System.setProperty("carbon.home", "/tmp/dummy-carbon-server");
-// }
-//
-// private Payload createPayload (PayloadArg payloadArg, String provider, String cartridgeType, String tenantDomain,
-// String cartridgeAlias) {
-//
-// Payload payload = null;
-// try {
-// payload = PayloadFactory.getPayloadDataInstance(provider, cartridgeType,
-// "/tmp/" + tenantDomain + "-" + cartridgeAlias + ".zip");
-//
-// } catch (ADCException e) {
-// throw new RuntimeException(e);
-// }
-// payload.populatePayload(payloadArg);
-// try {
-// payload.createPayload();
-//
-// } catch (ADCException e) {
-// throw new RuntimeException(e);
-// }
-//
-// return payload;
-// }
-//
-// private PayloadArg createBasePayloadArg (CartridgeInfo cartridgeInfo, boolean isMultitenant, String alias,
-// String type) {
-//
-// PayloadArg payloadArg = new PayloadArg();
-// payloadArg.setCartridgeInfo(cartridgeInfo);
-// payloadArg.setMultitenant(isMultitenant);
-// payloadArg.setTenantId(1);
-// payloadArg.setTenantDomain("foo.com");
-// payloadArg.setCartridgeAlias(alias);
-// payloadArg.setServiceName(type);
-//
-// return payloadArg;
-// }
-//
-// public void testMultitenantCarbonPayload() {
-//
-// CartridgeInfo cartridgeInfo = new CartridgeInfo();
-// cartridgeInfo.setMultiTenant(true);
-// cartridgeInfo.setType("esb");
-// PayloadArg payloadArg = createBasePayloadArg(cartridgeInfo, true, "carbon1", "esb");
-// payloadArg.setDeployment("default");
-// payloadArg.setHostName("esb.test.com");
-// payloadArg.setServiceDomain("esb.domain");
-// payloadArg.setServiceDomain("__$default");
-// Payload payload = createPayload(payloadArg, "wso2", "esb", "foo.com", "carbon1");
-// assertNotNull(payload);
-// //assertTrue(payload.delete());
-// }
-//
-// public void testSingleTenantCarbonPayload() {
-//
-// CartridgeInfo cartridgeInfo = new CartridgeInfo();
-// cartridgeInfo.setMultiTenant(false);
-// cartridgeInfo.setType("as");
-// PayloadArg payloadArg = createBasePayloadArg(cartridgeInfo, false, "carbon2", "as");
-// payloadArg.setDeployment("default");
-// payloadArg.setHostName("as.test.com");
-// payloadArg.setServiceDomain("as.domain");
-// payloadArg.setServiceDomain("__$default");
-// Payload payload = createPayload(payloadArg, "wso2", "as", "foo.com", "carbon2");
-// assertNotNull(payload);
-// //assertTrue(payload.delete());
-// }
-//
-// public void testNonCarbonPayload() {
-//
-// CartridgeInfo cartridgeInfo = new CartridgeInfo();
-// cartridgeInfo.setType("php");
-// //http port mapping
-// PortMapping httpPortMapping = new PortMapping();
-// httpPortMapping.setProtocol("http");
-// httpPortMapping.setPort("80");
-// httpPortMapping.setProxyPort("8280");
-// //https port mapping
-// PortMapping httpsPortMapping = new PortMapping();
-// httpsPortMapping.setProtocol("https");
-// httpsPortMapping.setPort("443");
-// httpsPortMapping.setProxyPort("8243");
-//
-// PortMapping[] portMappings = new PortMapping[]{httpPortMapping, httpsPortMapping};
-// cartridgeInfo.setPortMappings(portMappings);
-//
-// //auto scaling parameters
-// Policy autoScalePolicy = new Policy();
-// autoScalePolicy.setMinAppInstances(1);
-// autoScalePolicy.setMaxAppInstances(2);
-// autoScalePolicy.setAlarmingLowerRate(BigDecimal.valueOf(0.2));
-// autoScalePolicy.setAlarmingUpperRate(BigDecimal.valueOf(0.7));
-// autoScalePolicy.setMaxRequestsPerSecond(5);
-// autoScalePolicy.setScaleDownFactor(BigDecimal.valueOf(0.25));
-// autoScalePolicy.setRoundsToAverage(2);
-//
-// PayloadArg payloadArg = createBasePayloadArg(cartridgeInfo, false, "php1", "php");
-// payloadArg.setPolicy(autoScalePolicy);
-// payloadArg.setHostName("php.test.com");
-// payloadArg.setServiceDomain("php.domain");
-// payloadArg.setServiceDomain("__$default");
-// Payload payload = createPayload(payloadArg, "php-provider", "php", "foo.com", "php1");
-// assertNotNull(payload);
-// //assertTrue(payload.delete());
-// }
-//
-// public void testDataPayload() {
-//
-// CartridgeInfo cartridgeInfo = new CartridgeInfo();
-// cartridgeInfo.setType("php");
-// //http port mapping
-// PortMapping httpPortMapping = new PortMapping();
-// httpPortMapping.setProtocol("http");
-// httpPortMapping.setPort("80");
-// httpPortMapping.setProxyPort("8280");
-// //https port mapping
-// PortMapping httpsPortMapping = new PortMapping();
-// httpsPortMapping.setProtocol("https");
-// httpsPortMapping.setPort("443");
-// httpsPortMapping.setProxyPort("8243");
-//
-// PortMapping[] portMappings = new PortMapping[]{httpPortMapping, httpsPortMapping};
-// cartridgeInfo.setPortMappings(portMappings);
-//
-// //auto scaling parameters
-// Policy autoScalePolicy = new Policy();
-// autoScalePolicy.setMinAppInstances(1);
-// autoScalePolicy.setMaxAppInstances(2);
-// autoScalePolicy.setAlarmingLowerRate(BigDecimal.valueOf(0.2));
-// autoScalePolicy.setAlarmingUpperRate(BigDecimal.valueOf(0.7));
-// autoScalePolicy.setMaxRequestsPerSecond(5);
-// autoScalePolicy.setScaleDownFactor(BigDecimal.valueOf(0.25));
-// autoScalePolicy.setRoundsToAverage(2);
-//
-// PayloadArg payloadArg = createBasePayloadArg(cartridgeInfo, false, "mysql1", "mysql");
-// payloadArg.setPolicy(autoScalePolicy);
-// payloadArg.setHostName("mysql.test.com");
-// payloadArg.setServiceDomain("mysql.domain");
-// payloadArg.setServiceDomain("__$default");
-// Payload payload = createPayload(payloadArg, "mysql-provider", "mysql", "foo.com", "mysql1");
-// assertNotNull(payload);
-// //assertTrue(payload.delete());
-// }
-//
-// protected void tearDown() throws java.lang.Exception {
-//
-// System.clearProperty(CartridgeConstants.REPO_INFO_EPR);
-// System.clearProperty(CartridgeConstants.CARTRIDGE_AGENT_EPR);
-// System.clearProperty(CartridgeConstants.BAM_IP);
-// System.clearProperty(CartridgeConstants.BAM_PORT);
-// System.clearProperty("carbon.home");
-// }
-//}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PolicyHolderTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PolicyHolderTest.java b/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PolicyHolderTest.java
deleted file mode 100644
index 3b39d47..0000000
--- a/components/org.apache.stratos.manager/src/test/java/org/apache/stratos/manager/test/PolicyHolderTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-//package org.apache.stratos.manager.test;
-///*
-// *
-// * 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.
-// *
-//*/
-//
-//
-//import java.io.File;
-//import java.lang.reflect.Constructor;
-//import java.lang.reflect.InvocationTargetException;
-//
-//import junit.framework.TestCase;
-//
-//import org.apache.stratos.manager.utils.PolicyHolder;
-//
-//public class PolicyHolderTest extends TestCase {
-//
-// private PolicyHolder getPolicyHolder(String policiesXMLFile) {
-// File policiesXmlSchema = new File("src/main/resources/policies.xsd");
-// String dir = "src/test/resources/";
-//
-// Class<PolicyHolder> clazz = PolicyHolder.class;
-//
-// Constructor<PolicyHolder> c;
-// try {
-// c = clazz.getDeclaredConstructor(File.class, File.class);
-// c.setAccessible(true);
-// } catch (NoSuchMethodException e) {
-// throw new RuntimeException(e);
-// } catch (SecurityException e) {
-// throw new RuntimeException(e);
-// }
-// PolicyHolder policyHolder;
-// try {
-// policyHolder = c.newInstance(policiesXmlSchema, new File(dir, policiesXMLFile));
-// } catch (InstantiationException e) {
-// throw new RuntimeException(e);
-// } catch (IllegalAccessException e) {
-// throw new RuntimeException(e);
-// } catch (IllegalArgumentException e) {
-// throw new RuntimeException(e);
-// } catch (InvocationTargetException e) {
-// throw new RuntimeException(e);
-// }
-// return policyHolder;
-// }
-//
-// public void testDefaultPolicy() {
-// PolicyHolder policyHolder = getPolicyHolder("policies-1.xml");
-// assertNotNull(policyHolder);
-// assertNotNull(policyHolder.getDefaultPolicy());
-// }
-//
-//
-// public void testSinglePolicy() {
-// PolicyHolder policyHolder = getPolicyHolder("policies-1.xml");
-// assertNotNull(policyHolder);
-// assertNotNull(policyHolder.getPolicy("single"));
-// assertEquals("single", policyHolder.getPolicy("single").getName());
-// }
-//
-// public void testElasticPolicy() {
-// PolicyHolder policyHolder = getPolicyHolder("policies-1.xml");
-// assertNotNull(policyHolder);
-// assertNotNull(policyHolder.getPolicy("elastic"));
-// assertEquals("elastic", policyHolder.getPolicy("elastic").getName());
-// }
-//}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/test/resources/policies-1.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/test/resources/policies-1.xml b/components/org.apache.stratos.manager/src/test/resources/policies-1.xml
deleted file mode 100644
index efc24b7..0000000
--- a/components/org.apache.stratos.manager/src/test/resources/policies-1.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version='1.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.
-
--->
-
-<policies>
- <policy name="single" isDefault="true">
- <description>Single - Instances: Min 1, Max 1</description>
- <min_app_instances>1</min_app_instances>
- <max_app_instances>1</max_app_instances>
- <max_requests_per_second>5</max_requests_per_second>
- <alarming_upper_rate>0.7</alarming_upper_rate>
- <alarming_lower_rate>0.2</alarming_lower_rate>
- <scale_down_factor>0.25</scale_down_factor>
- <rounds_to_average>2</rounds_to_average>
- </policy>
- <policy name="elastic" isDefault="false">
- <description>Elastic - Instances: Min 1, Max 4</description>
- <min_app_instances>1</min_app_instances>
- <max_app_instances>4</max_app_instances>
- <max_requests_per_second>5</max_requests_per_second>
- <alarming_upper_rate>0.7</alarming_upper_rate>
- <alarming_lower_rate>0.2</alarming_lower_rate>
- <scale_down_factor>0.25</scale_down_factor>
- <rounds_to_average>2</rounds_to_average>
- </policy>
-</policies>
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
index bab037b..eb9b888 100644
--- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
+++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java
@@ -21,13 +21,10 @@ package org.apache.stratos.metadataservice.registry;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.internal.DataHolder;
-import org.apache.stratos.manager.registry.RegistryManager;
+import org.apache.stratos.manager.internal.ServiceReferenceHolder;
import org.apache.stratos.metadataservice.definition.NewProperty;
-import org.wso2.carbon.core.AbstractAdmin;
import org.wso2.carbon.registry.api.Registry;
import org.wso2.carbon.registry.api.RegistryException;
-import org.wso2.carbon.registry.api.RegistryService;
import org.wso2.carbon.registry.api.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -62,7 +59,7 @@ public class CarbonRegistry implements DataStore {
* @throws RegistryException
*/
public List<NewProperty> getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException {
- Registry tempRegistry = DataHolder.getRegistryService().getRegistry();
+ Registry tempRegistry = ServiceReferenceHolder.getRegistryService().getRegistry();
String resourcePath = mainResource + applicationName + "/" + clusterId;
if (!tempRegistry.resourceExists(resourcePath)) {
return null;
@@ -96,7 +93,7 @@ public class CarbonRegistry implements DataStore {
* @throws RegistryException
*/
public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException {
- Registry tempRegistry = DataHolder.getRegistryService().getRegistry();
+ Registry tempRegistry = ServiceReferenceHolder.getRegistryService().getRegistry();
String resourcePath = mainResource + applicationId + "/" + clusterId;
Resource regResource = createOrGetResourceforCluster(tempRegistry, resourcePath);
@@ -116,7 +113,7 @@ public class CarbonRegistry implements DataStore {
if(StringUtils.isBlank(applicationId)){
throw new IllegalArgumentException("Application ID can not be null");
}
- Registry tempRegistry = DataHolder.getRegistryService().getRegistry();
+ Registry tempRegistry = ServiceReferenceHolder.getRegistryService().getRegistry();
String resourcePath = mainResource + applicationId;
if(tempRegistry.resourceExists(resourcePath)){
@@ -136,7 +133,7 @@ public class CarbonRegistry implements DataStore {
* @throws RegistryException
*/
public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException {
- Registry tempRegistry = DataHolder.getRegistryService().getRegistry();
+ Registry tempRegistry = ServiceReferenceHolder.getRegistryService().getRegistry();
String resourcePath = mainResource + applicationName + "/" + clusterId;
Resource regResource;
regResource = createOrGetResourceforCluster(tempRegistry, resourcePath);
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
index 81be753..3bdc928 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40.java
@@ -22,11 +22,9 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
-import org.apache.stratos.common.exception.ApacheStratosException;
import org.apache.stratos.common.util.ClaimsMgtUtil;
import org.apache.stratos.common.util.CommonUtil;
-import org.apache.stratos.manager.dto.Cartridge;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
+import org.apache.stratos.manager.domain.Cartridge;
import org.apache.stratos.rest.endpoint.ServiceHolder;
import org.apache.stratos.rest.endpoint.Utils;
import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
@@ -314,10 +312,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cartridge[] getSubscribedCartridges() throws RestAPIException {
- List<Cartridge> cartridgeList = StratosApiV40Utils.getSubscriptions(null, null, getConfigContext());
- // Following is very important when working with axis2
- return cartridgeList.isEmpty() ? new Cartridge[0] : cartridgeList.toArray(new Cartridge[cartridgeList.size()]);
+ public Response getSubscribedCartridges() throws RestAPIException {
+ return Response.status(404).build();
}
@GET
@@ -325,10 +321,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cartridge[] getSubscribedCartridgesForServiceGroup(@PathParam("serviceGroup") String serviceGroup) throws RestAPIException {
- List<Cartridge> cartridgeList = StratosApiV40Utils.getSubscriptions(null, serviceGroup, getConfigContext());
- // Following is very important when working with axis2
- return cartridgeList.isEmpty() ? new Cartridge[0] : cartridgeList.toArray(new Cartridge[cartridgeList.size()]);
+ public Response getSubscribedCartridgesForServiceGroup(@PathParam("serviceGroup") String serviceGroup) throws RestAPIException {
+ return Response.status(404).build();
}
@GET
@@ -336,8 +330,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cartridge getCartridgeInfo(@PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException {
- return StratosApiV40Utils.getSubscription(subscriptionAlias, getConfigContext());
+ public Response getCartridgeInfo(@PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException {
+ return Response.status(404).build();
}
@GET
@@ -365,9 +359,9 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public int getActiveInstances(@PathParam("cartridgeType") String cartridgeType,
- @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException {
- return StratosApiV40Utils.getActiveInstances(cartridgeType, subscriptionAlias, getConfigContext());
+ public Response getActiveInstances(@PathParam("cartridgeType") String cartridgeType,
+ @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException {
+ return Response.status(404).build();
}
@POST
@@ -385,9 +379,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cluster[] getClustersForTenant() throws RestAPIException {
-
- return StratosApiV40Utils.getClustersForTenant(getConfigContext());
+ public Response getClustersForTenant() throws RestAPIException {
+ return Response.status(404).build();
}
@GET
@@ -395,8 +388,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cluster[] getClusters(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException {
- return StratosApiV40Utils.getClustersForCartridgeType(cartridgeType);
+ public Response getClusters(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException {
+ return Response.status(404).build();
}
@GET
@@ -404,9 +397,9 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cluster[] getServiceClusters(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException {
+ public Response getServiceClusters(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException {
- return StratosApiV40Utils.getClustersForTenantAndCartridgeType(getConfigContext(), cartridgeType);
+ return Response.status(404).build();
}
@GET
@@ -414,10 +407,10 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cluster getCluster(@PathParam("cartridgeType") String cartridgeType,
- @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException, RestAPIException {
+ public Response getCluster(@PathParam("cartridgeType") String cartridgeType,
+ @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException, RestAPIException {
- return StratosApiV40Utils.getCluster(cartridgeType, subscriptionAlias, getConfigContext());
+ return Response.status(404).build();
}
@GET
@@ -425,25 +418,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public Cluster getCluster(@PathParam("clusterId") String clusterId) throws RestAPIException {
- Cluster cluster = null;
- if(log.isDebugEnabled()) {
- log.debug("Finding cluster for [id]: "+clusterId);
- }
- Cluster[] clusters = StratosApiV40Utils.getClustersForTenant(getConfigContext());
- if(log.isDebugEnabled()) {
- log.debug("Clusters retrieved from backend for cluster [id]: "+clusterId);
- for (Cluster c : clusters) {
- log.debug(c+"\n");
- }
- }
- for (Cluster clusterObj : clusters) {
- if (clusterObj.getClusterId().equals(clusterId)){
- cluster = clusterObj;
- break;
- }
- }
- return cluster;
+ public Response getCluster(@PathParam("clusterId") String clusterId) throws RestAPIException {
+ throw new RestAPIException("Not implemented");
}
@POST
@@ -922,16 +898,9 @@ public class StratosApiV40 extends AbstractApi {
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
@SuperTenantService(true)
- public StratosApiResponse deployService (ServiceDefinitionBean serviceDefinitionBean)
+ public Response deployService(ServiceDefinitionBean serviceDefinitionBean)
throws RestAPIException {
-
- log.info("Service definition request.. : " + serviceDefinitionBean.getServiceName());
- // super tenant Deploying service (MT)
- // here an alias is generated
- return StratosApiV40Utils.deployService(serviceDefinitionBean.getCartridgeType(), UUID.randomUUID().toString(), serviceDefinitionBean.getAutoscalingPolicyName(),
- serviceDefinitionBean.getDeploymentPolicyName(), getTenantDomain(), getUsername(), getTenantId(),
- serviceDefinitionBean.getClusterDomain(), serviceDefinitionBean.getClusterSubDomain(),
- serviceDefinitionBean.getTenantRange());
+ return Response.status(404).build();
}
@GET
@@ -939,10 +908,9 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public ServiceDefinitionBean[] getServices() throws RestAPIException {
- List<ServiceDefinitionBean> serviceDefinitionBeans = StratosApiV40Utils.getdeployedServiceInformation();
- return serviceDefinitionBeans == null || serviceDefinitionBeans.isEmpty() ? new ServiceDefinitionBean[0] :
- serviceDefinitionBeans.toArray(new ServiceDefinitionBean[serviceDefinitionBeans.size()]);
+ public Response getServices() throws RestAPIException {
+ return Response.status(404).build();
+
}
@GET
@@ -950,9 +918,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public ServiceDefinitionBean getService(@PathParam("serviceType") String serviceType)throws RestAPIException {
-
- return StratosApiV40Utils.getDeployedServiceInformation(serviceType);
+ public Response getService(@PathParam("serviceType") String serviceType)throws RestAPIException {
+ return Response.status(404).build();
}
@GET
@@ -960,9 +927,8 @@ public class StratosApiV40 extends AbstractApi {
@Produces("application/json")
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
- public List<Cartridge> getActiveService()throws RestAPIException {
-
- return StratosApiV40Utils.getActiveDeployedServiceInformation(getConfigContext());
+ public Response getActiveService()throws RestAPIException {
+ return Response.status(404).build();
}
@DELETE
@@ -971,10 +937,9 @@ public class StratosApiV40 extends AbstractApi {
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
@SuperTenantService(true)
- public StratosApiResponse unDeployService (@PathParam("serviceType") String serviceType)
+ public Response unDeployService (@PathParam("serviceType") String serviceType)
throws RestAPIException {
-
- return StratosApiV40Utils.undeployService(serviceType);
+ return Response.status(404).build();
}
@POST
@@ -995,12 +960,13 @@ public class StratosApiV40 extends AbstractApi {
if (log.isDebugEnabled()) {
log.debug(String.format("Synchronizing Git repository for alias '%s'", alias));
}
- CartridgeSubscription cartridgeSubscription = StratosApiV40Utils.getCartridgeSubscription(alias, getConfigContext());
- if (cartridgeSubscription != null && cartridgeSubscription.getRepository() != null && log.isDebugEnabled()) {
- log.debug(String.format("Found subscription for '%s'. Git repository: %s", alias, cartridgeSubscription
- .getRepository().getUrl()));
- }
- return StratosApiV40Utils.synchronizeRepository(cartridgeSubscription);
+// CartridgeSubscription cartridgeSubscription = StratosApiV40Utils.getCartridgeSubscription(alias, getConfigContext());
+// if (cartridgeSubscription != null && cartridgeSubscription.getRepository() != null && log.isDebugEnabled()) {
+// log.debug(String.format("Found subscription for '%s'. Git repository: %s", alias, cartridgeSubscription
+// .getRepository().getUrl()));
+// }
+// return StratosApiV40Utils.synchronizeRepository(cartridgeSubscription);
+ throw new RestAPIException("Not implemented");
}
private List<TenantInfoBean> getAllTenants() throws RestAPIException {
@@ -1060,13 +1026,14 @@ public class StratosApiV40 extends AbstractApi {
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
public Response getSubscriptionDomains(@PathParam("cartridgeType") String cartridgeType,
@PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException {
- SubscriptionDomainBean[] subscriptionDomainBean = StratosApiV40Utils.getSubscriptionDomains(getConfigContext(), cartridgeType, subscriptionAlias).toArray(new SubscriptionDomainBean[0]);
-
- if(subscriptionDomainBean.length == 0){
- return Response.status(Response.Status.NOT_FOUND).build();
- }else{
- return Response.ok().entity(subscriptionDomainBean).build();
- }
+// SubscriptionDomainBean[] subscriptionDomainBean = StratosApiV40Utils.getSubscriptionDomains(getConfigContext(), cartridgeType, subscriptionAlias).toArray(new SubscriptionDomainBean[0]);
+//
+// if(subscriptionDomainBean.length == 0){
+// return Response.status(Response.Status.NOT_FOUND).build();
+// }else{
+// return Response.ok().entity(subscriptionDomainBean).build();
+// }
+ throw new RestAPIException("Not implemented");
}
@GET
@@ -1075,12 +1042,13 @@ public class StratosApiV40 extends AbstractApi {
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
public Response getSubscriptionDomain(@PathParam("cartridgeType") String cartridgeType,
@PathParam("subscriptionAlias") String subscriptionAlias, @PathParam("domainName") String domainName) throws RestAPIException {
- SubscriptionDomainBean subscriptionDomainBean = StratosApiV40Utils.getSubscriptionDomain(getConfigContext(), cartridgeType, subscriptionAlias, domainName);
- if(subscriptionDomainBean.getDomainName() == null){
- return Response.status(Response.Status.NOT_FOUND).build();
- }else{
- return Response.ok().entity(subscriptionDomainBean).build();
- }
+// SubscriptionDomainBean subscriptionDomainBean = StratosApiV40Utils.getSubscriptionDomain(getConfigContext(), cartridgeType, subscriptionAlias, domainName);
+// if(subscriptionDomainBean.getDomainName() == null){
+// return Response.status(Response.Status.NOT_FOUND).build();
+// }else{
+// return Response.ok().entity(subscriptionDomainBean).build();
+// }
+ throw new RestAPIException("Not implemented");
}
@DELETE
@@ -1099,23 +1067,6 @@ public class StratosApiV40 extends AbstractApi {
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
public Response getLoadBalancerCluster(@PathParam("cartridgeType") String cartridgeType,
@PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException {
- if (log.isDebugEnabled()) {
- log.debug(String.format("GET /cartridge/%s/subscription/%s/load-balancer-cluster", cartridgeType, subscriptionAlias));
- }
- Cartridge subscription = StratosApiV40Utils.getSubscription(subscriptionAlias, getConfigContext());
- String lbClusterId = subscription.getLbClusterId();
- if (log.isDebugEnabled()) {
- log.debug(String.format("Load balancer cluster-id found: %s", lbClusterId));
- }
- if (StringUtils.isNotBlank(lbClusterId)) {
- Cluster lbCluster = getCluster(lbClusterId);
- if (lbCluster != null) {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Load balancer cluster found: %s", lbCluster.toString()));
- }
- Response.ok().entity(lbCluster).build();
- }
- }
- return Response.status(Response.Status.NOT_FOUND).build();
+ return Response.status(404).build();
}
}
[09/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java
deleted file mode 100644
index 7a574bb..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/TenantUserRoleCreator.java
+++ /dev/null
@@ -1,119 +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.manager.listener;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.TenantInfoBean;
-import org.apache.stratos.common.exception.ApacheStratosException;
-import org.apache.stratos.common.listeners.TenantMgtListener;
-import org.apache.stratos.manager.internal.DataHolder;
-import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
-import org.apache.stratos.manager.utils.UserRoleCreator;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.user.api.UserStoreManager;
-import org.wso2.carbon.user.api.UserRealm;
-
-/**
- * Listener for Tenant create event to create a new Role
- */
-public class TenantUserRoleCreator implements TenantMgtListener {
-
- private static final Log log = LogFactory.getLog(TenantUserRoleCreator.class);
-
- /**
- * Create an 'user' role at tenant creation time
- * @param tenantInfo TenantInfoBean
- * @throws org.apache.stratos.common.exception.ApacheStratosException
- */
- @Override
- public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException {
-
- try {
-
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(tenantInfo.getTenantDomain());
- carbonContext.setTenantId(tenantInfo.getTenantId());
- //Get tenant UserRealm & UserStoreManager
- UserRealm userRealm = DataHolder.getRealmService().getTenantUserRealm(tenantInfo.getTenantId());
- UserStoreManager userStoreManager = userRealm.getUserStoreManager();
- //Call Util class to create the user role
-
- UserRoleCreator.createTenantUserRole(userStoreManager);
-
- } catch (UserStoreException e) {
- String msg = "Error while retrieving the user store for tenant: "+ tenantInfo.getTenantDomain();
- log.error(msg, e);
- throw new ApacheStratosException(e.getMessage(), e);
- } catch (UserManagerException e) {
- String msg = "Error while creating the user role in tenant: "+ tenantInfo.getTenantDomain();
- log.error(msg, e);
- throw new ApacheStratosException(e.getMessage(), e);
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- }
-
-
- @Override
- public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException {
-
- }
-
- @Override
- public void onTenantDelete(int tenantId) {
-
- }
-
- @Override
- public void onTenantRename(int tenantId, String oldDomainName, String newDomainName)
- throws ApacheStratosException {
-
- }
-
- @Override
- public void onTenantInitialActivation(int tenantId) throws ApacheStratosException {
-
- }
-
- @Override
- public void onTenantActivation(int tenantId) throws ApacheStratosException {
-
- }
-
- @Override
- public void onTenantDeactivation(int tenantId) throws ApacheStratosException {
-
- }
-
- @Override
- public void onSubscriptionPlanChange(int tenentId, String oldPlan, String newPlan)
- throws ApacheStratosException {
-
- }
-
- @Override
- public int getListenerOrder() {
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/ClusterIdToSubscription.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/ClusterIdToSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/ClusterIdToSubscription.java
deleted file mode 100644
index a994a73..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/ClusterIdToSubscription.java
+++ /dev/null
@@ -1,102 +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.manager.lookup;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.io.Serializable;
-import java.util.*;
-
-public class ClusterIdToSubscription implements Serializable {
-
- private static final Log log = LogFactory.getLog(ClusterIdToSubscription.class);
-
- // Map: Cluster Id (Domain) -> Set<CartridgeSubscription>
- private Map<String, Set<CartridgeSubscription>> clusterIdToCartridgeSubscription;
-
- public ClusterIdToSubscription() {
- clusterIdToCartridgeSubscription = new HashMap<String, Set<CartridgeSubscription>>();
- }
-
- public void addSubscription (CartridgeSubscription cartridgeSubscription) {
-
- //clusterIdToCartridgeSubscription.put(cartridgeSubscription.getClusterDomain(), cartridgeSubscription);
- String clusterDomain = cartridgeSubscription.getClusterDomain();
- if (clusterIdToCartridgeSubscription.containsKey(clusterDomain)) {
- Set<CartridgeSubscription> existingSubscriptions = clusterIdToCartridgeSubscription.get(clusterDomain);
- // if an existing subscription is present, remove it
- if(existingSubscriptions.remove(cartridgeSubscription)){
- if(log.isDebugEnabled()) {
- log.debug("Removed the existing Cartridge Subscription for cluster id " + clusterDomain + " in [Cluster Id -> Set<CartridgeSubscription>] map");
- }
- }
- // add or update
- existingSubscriptions.add(cartridgeSubscription);
- if(log.isDebugEnabled()) {
- log.debug("Added Cartridge Subscription for cluster id " + clusterDomain + " in [Cluster Id -> Set<CartridgeSubscription>] map");
- }
-
- } else {
- // create a new set and add it
- Set<CartridgeSubscription> subscriptions = new HashSet<CartridgeSubscription>();
- subscriptions.add(cartridgeSubscription);
- clusterIdToCartridgeSubscription.put(clusterDomain, subscriptions);
- if(log.isDebugEnabled()) {
- log.debug("Added Cartridge Subscription for cluster id " + clusterDomain + " in [Cluster Id -> Set<CartridgeSubscription>] map");
- }
- }
- }
-
- public Set<CartridgeSubscription> getSubscription (String clusterId) {
-
- return clusterIdToCartridgeSubscription.get(clusterId);
- }
-
- public void removeSubscription (String clusterId, String subscriptionAlias) {
-
- // remove Subscription from clusterIdToCartridgeSubscription map
- Set<CartridgeSubscription> existingSubscriptions = clusterIdToCartridgeSubscription.get(clusterId);
- if (existingSubscriptions != null && !existingSubscriptions.isEmpty()) {
- // iterate through the set
- Iterator<CartridgeSubscription> iterator = existingSubscriptions.iterator();
- while (iterator.hasNext()) {
- CartridgeSubscription cartridgeSubscription = iterator.next();
- // if a matching CartridgeSubscription is found, remove
- if (cartridgeSubscription.getAlias().equals(subscriptionAlias)) {
- iterator.remove();
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscription for cluster id " + clusterId + " from [Cluster Id -> Set<CartridgeSubscription>] map");
- }
- break;
- }
- }
- }
-
- // if the Subscriptions set is empty now, remove it from cartridgeTypeToSubscriptions map
- if (existingSubscriptions == null || existingSubscriptions.isEmpty()) {
- clusterIdToCartridgeSubscription.remove(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscriptions set for cluster id " + clusterId + " from [Cluster Id -> Set<CartridgeSubscription>] map");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/LookupDataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/LookupDataHolder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/LookupDataHolder.java
deleted file mode 100644
index de66815..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/LookupDataHolder.java
+++ /dev/null
@@ -1,210 +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.manager.lookup;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-public class LookupDataHolder implements Serializable {
-
- private static final Log log = LogFactory.getLog(LookupDataHolder.class);
-
- private ClusterIdToSubscription clusterIdToSubscription;
- private TenantIdToSubscriptionContext tenantIdToSubscriptionContext;
- private RepoUrlToCartridgeSubscriptions repoUrlToCartridgeSubscriptions;
- private static volatile LookupDataHolder lookupDataHolder;
-
- //locks
- private static volatile ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
- private static volatile ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();
- private static volatile ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
-
- private LookupDataHolder () {
- clusterIdToSubscription = new ClusterIdToSubscription();
- tenantIdToSubscriptionContext = new TenantIdToSubscriptionContext();
- repoUrlToCartridgeSubscriptions = new RepoUrlToCartridgeSubscriptions();
- }
-
- public static LookupDataHolder getInstance () {
-
- if (lookupDataHolder == null) {
- synchronized (LookupDataHolder.class) {
- if (lookupDataHolder == null) {
- lookupDataHolder = new LookupDataHolder();
- }
- }
- }
- return lookupDataHolder;
- }
-
- public void putSubscription (CartridgeSubscription cartridgeSubscription) {
-
- // add or update
- clusterIdToSubscription.addSubscription(cartridgeSubscription);
-
- repoUrlToCartridgeSubscriptions.addSubscription(cartridgeSubscription);
-
- // check if an existing SubscriptionContext is available
- SubscriptionContext existingSubscriptionCtx = tenantIdToSubscriptionContext.getSubscriptionContext(cartridgeSubscription.getSubscriber().getTenantId());
- if(existingSubscriptionCtx != null) {
- if (log.isDebugEnabled()) {
- log.debug("Existing SubscriptionContext found for tenant " + cartridgeSubscription.getSubscriber().getTenantId());
- }
- existingSubscriptionCtx.addSubscription(cartridgeSubscription);
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Existing SubscriptionContext not found for tenant " + cartridgeSubscription.getSubscriber().getTenantId());
- }
- //create a new subscription context and add the subscription
- SubscriptionContext subscriptionContext = new SubscriptionContext();
- subscriptionContext.addSubscription(cartridgeSubscription);
- tenantIdToSubscriptionContext.addSubscriptionContext(cartridgeSubscription.getSubscriber().getTenantId(), subscriptionContext);
- }
-
- }
-
- public void removeSubscription (int tenantId, String type, String subscriptionAlias, String clusterId, String repoUrl) {
-
- tenantIdToSubscriptionContext.removeSubscriptionContext(tenantId, type, subscriptionAlias);
- clusterIdToSubscription.removeSubscription(clusterId, subscriptionAlias);
- repoUrlToCartridgeSubscriptions.removeSubscription(repoUrl, subscriptionAlias);
- }
-
- public Collection<CartridgeSubscription> getSubscriptions (String cartridgeType) {
-
- Collection<SubscriptionContext> subscriptionContexts = tenantIdToSubscriptionContext.getSubscriptionContexts();
- if (subscriptionContexts == null) {
- // no subscriptions
- return null;
- }
-
- Collection<CartridgeSubscription> cartridgeSubscriptions = new ArrayList<CartridgeSubscription>();
- // iterate through the SubscriptionContexts
- for (SubscriptionContext subscriptionContext : subscriptionContexts) {
- // check if CartridgeSubscriptions exist for the given type, in each SubscriptionContext instance
- Collection<CartridgeSubscription> cartridgeSubscriptionsOfType = subscriptionContext.getSubscriptionsOfType(cartridgeType);
- if (cartridgeSubscriptionsOfType != null && !cartridgeSubscriptionsOfType.isEmpty()) {
- // collect the relevant CartridgeSubscriptions
- cartridgeSubscriptions.addAll(cartridgeSubscriptionsOfType);
- }
- }
-
- return cartridgeSubscriptions;
- }
-
- public Collection<CartridgeSubscription> getSubscriptions (int tenantId) {
-
- SubscriptionContext subscriptionContext = tenantIdToSubscriptionContext.getSubscriptionContext(tenantId);
- if (subscriptionContext == null) {
- // no subscriptions
- return null;
- }
-
- return subscriptionContext.getSubscriptions();
-
- }
-
- public CartridgeSubscription getSubscriptionForAlias (String subscriptionAlias) {
-
- Collection<SubscriptionContext> subscriptionContexts = tenantIdToSubscriptionContext.getSubscriptionContexts();
- if (subscriptionContexts == null) {
- // no subscriptions
- return null;
- }
-
- CartridgeSubscription cartridgeSubscription;
-
- for (SubscriptionContext subscriptionContext : subscriptionContexts) {
- cartridgeSubscription = subscriptionContext.getSubscriptionForAlias(subscriptionAlias);
- // check if the retrieved subscription is not null and return
- if (cartridgeSubscription != null) {
- return cartridgeSubscription;
- }
- }
-
- return null;
- }
-
- public Collection<CartridgeSubscription> getSubscriptionForType (int tenantId, String cartridgeType) {
-
- SubscriptionContext subscriptionContext = tenantIdToSubscriptionContext.getSubscriptionContext(tenantId);
- if (subscriptionContext == null) {
- // no subscriptions
- return null;
- }
-
- return subscriptionContext.getSubscriptionsOfType(cartridgeType);
- }
-
- public CartridgeSubscription getSubscriptionForAlias (int tenantId, String subscriptionAlias) {
-
- SubscriptionContext subscriptionContext = tenantIdToSubscriptionContext.getSubscriptionContext(tenantId);
- if (subscriptionContext == null) {
- // no subscriptions
- if (log.isDebugEnabled()) {
- log.debug("No SubscriptionContext found for tenant " + tenantId + ", subscription alias " + subscriptionAlias);
- }
- return null;
- }
-
- return subscriptionContext.getSubscriptionForAlias(subscriptionAlias);
-
- }
-
- public Set<CartridgeSubscription> getSubscription (String clusterId) {
-
- return clusterIdToSubscription.getSubscription(clusterId);
-
- }
-
- public Set<CartridgeSubscription> getSubscriptionsForRepoUrl (String repoUrl) {
-
- return repoUrlToCartridgeSubscriptions.getSubscriptions(repoUrl);
-
- }
-
- public void acquireWriteLock () {
-
- writeLock.lock();
- }
-
- public void releaseWriteLock () {
-
- writeLock.unlock();
- }
-
- public void acquireReadLock () {
-
- readLock.lock();
- }
-
- public void releaseReadLock () {
-
- readLock.unlock();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java
deleted file mode 100644
index d0d7396..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/RepoUrlToCartridgeSubscriptions.java
+++ /dev/null
@@ -1,116 +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.manager.lookup;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.util.*;
-
-public class RepoUrlToCartridgeSubscriptions {
-
- private static final Log log = LogFactory.getLog(RepoUrlToCartridgeSubscriptions.class);
-
- // Map: Repository URL -> Set<CartridgeSubscription>
- private Map<String, Set<CartridgeSubscription>> repoUrlToCartridgeSubscriptions;
-
- public RepoUrlToCartridgeSubscriptions() {
- repoUrlToCartridgeSubscriptions = new HashMap<String, Set<CartridgeSubscription>>();
- }
-
- public void addSubscription (CartridgeSubscription cartridgeSubscription) {
-
- if (cartridgeSubscription.getRepository() == null) {
- if (log.isDebugEnabled()) {
- log.debug("No repository URL found for Cartridge Subscription for alias " + cartridgeSubscription.getAlias() +
- ", not adding to [Repo URL -> Set<CartridgeSubscription>] map");
- }
- return;
- }
-
- String repoUrl = cartridgeSubscription.getRepository().getUrl();
-
- if (repoUrlToCartridgeSubscriptions.containsKey(repoUrl)) {
- Set<CartridgeSubscription> existingSubscriptions = repoUrlToCartridgeSubscriptions.get(repoUrl);
- // if an existing subscription is present, remove it
- if(existingSubscriptions.remove(cartridgeSubscription)){
- if(log.isDebugEnabled()) {
- log.debug("Removed the existing Cartridge Subscription for repo URL " + repoUrl + " in [Repo URL -> Set<CartridgeSubscription>] map");
- }
- }
- // add or update
- existingSubscriptions.add(cartridgeSubscription);
- if(log.isDebugEnabled()) {
- log.debug("Added Cartridge Subscription for repo URL " + repoUrl + " in [Repo URL -> Set<CartridgeSubscription>] map");
- }
-
- } else {
- // create a new set and add it
- Set<CartridgeSubscription> subscriptions = new HashSet<CartridgeSubscription>();
- subscriptions.add(cartridgeSubscription);
- repoUrlToCartridgeSubscriptions.put(repoUrl, subscriptions);
- if(log.isDebugEnabled()) {
- log.debug("Added Cartridge Subscription for repo URL " + repoUrl + " in [Repo URL -> Set<CartridgeSubscription>] map");
- }
- }
- }
-
- public Set<CartridgeSubscription> getSubscriptions(String repoUrl) {
-
- return repoUrlToCartridgeSubscriptions.get(repoUrl);
- }
-
- public void removeSubscription (String repoUrl, String subscriptionAlias) {
-
- if (repoUrl == null) {
- if (log.isDebugEnabled()) {
- log.debug("Repository URL is null for subscription alias " + subscriptionAlias);
- }
- return;
- }
-
- // remove Subscription from repoUrlToCartridgeSubscriptions map
- Set<CartridgeSubscription> existingSubscriptions = repoUrlToCartridgeSubscriptions.get(repoUrl);
- if (existingSubscriptions != null && !existingSubscriptions.isEmpty()) {
- // iterate through the set
- Iterator<CartridgeSubscription> iterator = existingSubscriptions.iterator();
- while (iterator.hasNext()) {
- CartridgeSubscription cartridgeSubscription = iterator.next();
- // if a matching CartridgeSubscription is found, remove
- if (cartridgeSubscription.getAlias().equals(subscriptionAlias)) {
- iterator.remove();
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscription for repo URL " + repoUrl + " from [Repo URL -> Set<CartridgeSubscription>] map");
- }
- break;
- }
- }
- }
-
- // if the Subscriptions set is empty now, remove it from cartridgeTypeToSubscriptions map
- if (existingSubscriptions == null || existingSubscriptions.isEmpty()) {
- repoUrlToCartridgeSubscriptions.remove(repoUrl);
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscriptions set for repo URL " + repoUrl + " from [Repo URL -> Set<CartridgeSubscription>] map");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/SubscriptionContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/SubscriptionContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/SubscriptionContext.java
deleted file mode 100644
index 61e6ed6..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/SubscriptionContext.java
+++ /dev/null
@@ -1,138 +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.manager.lookup;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.io.Serializable;
-import java.util.*;
-
-public class SubscriptionContext implements Serializable {
-
- private static final Log log = LogFactory.getLog(SubscriptionContext.class);
-
- // Map: Cartridge Type -> Set<CartridgeSubscription>
- private Map<String, Set<CartridgeSubscription>> cartridgeTypeToSubscriptions;
-
- // Map: Subscription Alias -> CartridgeSubscription
- private Map<String, CartridgeSubscription> aliasToSubscription;
-
- public SubscriptionContext () {
-
- cartridgeTypeToSubscriptions = new HashMap<String, Set<CartridgeSubscription>>();
- aliasToSubscription = new HashMap<String, CartridgeSubscription>();
- }
-
- public void addSubscription (CartridgeSubscription cartridgeSubscription) {
-
- String cartridgeType = cartridgeSubscription.getType();
- if (cartridgeTypeToSubscriptions.containsKey(cartridgeType)) {
- Set<CartridgeSubscription> existingSubscriptions = cartridgeTypeToSubscriptions.get(cartridgeType);
- // if an existing subscription is present, remove it
- if(existingSubscriptions.remove(cartridgeSubscription)){
- if(log.isDebugEnabled()) {
- log.debug("Removed the existing Cartridge Subscription for type " + cartridgeType + ", alias " + cartridgeSubscription.getAlias() +
- " in [Cartridge Type -> Set<CartridgeSubscription>] map");
- }
- }
- // add or update
- existingSubscriptions.add(cartridgeSubscription);
- if(log.isDebugEnabled()) {
- log.debug("Added Cartridge Subscription for type " + cartridgeType + ", alias " + cartridgeSubscription.getAlias() +
- " in [Cartridge Type -> Set<CartridgeSubscription>] map");
- }
-
- } else {
- // create a new set and add it
- Set<CartridgeSubscription> subscriptions = new HashSet<CartridgeSubscription>();
- subscriptions.add(cartridgeSubscription);
- cartridgeTypeToSubscriptions.put(cartridgeType, subscriptions);
- }
-
- // put Subscription to aliasToSubscription map
- if (aliasToSubscription.put(cartridgeSubscription.getAlias(), cartridgeSubscription) != null) {
- if(log.isDebugEnabled()) {
- log.debug("Overwrote the existing Cartridge Subscription for alias " + cartridgeSubscription.getAlias() +
- " in [Subscription Alias -> CartridgeSubscription] map");
- }
- }
- }
-
- public Collection<CartridgeSubscription> getSubscriptions () {
-
- return aliasToSubscription.values();
- }
-
- public Collection<CartridgeSubscription> getSubscriptionsOfType (String cartridgeType) {
-
- return cartridgeTypeToSubscriptions.get(cartridgeType);
- }
-
-
-
- public CartridgeSubscription getSubscriptionForAlias (String subscriptionAlias) {
-
- return aliasToSubscription.get(subscriptionAlias);
- }
-
- public void deleteSubscription (String type, String subscriptionAlias) {
-
- // remove Subscription from cartridgeTypeToSubscriptions map
- Set<CartridgeSubscription> existingSubscriptions = cartridgeTypeToSubscriptions.get(type);
- if (existingSubscriptions != null && !existingSubscriptions.isEmpty()) {
- // iterate through the set
- Iterator<CartridgeSubscription> iterator = existingSubscriptions.iterator();
- while (iterator.hasNext()) {
- CartridgeSubscription cartridgeSubscription = iterator.next();
- // if a matching CartridgeSubscription is found, remove
- if (cartridgeSubscription.getAlias().equals(subscriptionAlias)) {
- iterator.remove();
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscription for alias " + subscriptionAlias + " and type " + type + " from [Type -> Set<CartridgeSubscription>] map");
- }
- break;
- }
- }
- }
-
- // if the Subscriptions set is empty now, remove it from cartridgeTypeToSubscriptions map
- if (existingSubscriptions == null || existingSubscriptions.isEmpty()) {
- cartridgeTypeToSubscriptions.remove(type);
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscriptions set for type " + type + " from [Type -> Set<CartridgeSubscription>] map");
- }
- }
-
- // remove from aliasToSubscription map
- if (aliasToSubscription.remove(subscriptionAlias) != null) {
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscription for alias " + subscriptionAlias + " from [Alias -> CartridgeSubscription] map");
- }
- }
- }
-
- public boolean isEmpty () {
-
- return cartridgeTypeToSubscriptions.isEmpty() && aliasToSubscription.isEmpty();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/TenantIdToSubscriptionContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/TenantIdToSubscriptionContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/TenantIdToSubscriptionContext.java
deleted file mode 100644
index 0912d83..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lookup/TenantIdToSubscriptionContext.java
+++ /dev/null
@@ -1,70 +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.manager.lookup;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-public class TenantIdToSubscriptionContext {
-
- private static final Log log = LogFactory.getLog(TenantIdToSubscriptionContext.class);
-
- // Map: tenant Id -> SubscriptionContext
- private Map<Integer, SubscriptionContext> tenantIdToSubscriptionContext;
-
- public TenantIdToSubscriptionContext() {
- tenantIdToSubscriptionContext = new HashMap<Integer, SubscriptionContext>();
- }
-
- public Collection<SubscriptionContext> getSubscriptionContexts () {
-
- return tenantIdToSubscriptionContext.values();
- }
-
- public SubscriptionContext getSubscriptionContext (int tenantId) {
-
- return tenantIdToSubscriptionContext.get(tenantId);
- }
-
- public void addSubscriptionContext (int tenantId, SubscriptionContext subscriptionContext) {
-
- tenantIdToSubscriptionContext.put(tenantId, subscriptionContext);
- }
-
- public void removeSubscriptionContext (int tenantId, String type, String subscriptionAlias) {
-
- if (tenantIdToSubscriptionContext.containsKey(tenantId)) {
- SubscriptionContext subscriptionContext = tenantIdToSubscriptionContext.get(tenantId);
- subscriptionContext.deleteSubscription(type, subscriptionAlias);
-
- // delete the SubscriptionContext instance for the tenant if it carries no information
- if (subscriptionContext.isEmpty()) {
- tenantIdToSubscriptionContext.remove(tenantId);
- if (log.isDebugEnabled()) {
- log.debug("Deleted the subscriptionContext instance for tenant " + tenantId);
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
deleted file mode 100644
index d2a92e1..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/manager/CartridgeSubscriptionManager.java
+++ /dev/null
@@ -1,803 +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.manager.manager;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.cloud.controller.stub.CloudControllerServiceCartridgeNotFoundExceptionException;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.common.Property;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.dto.SubscriptionInfo;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.internal.DataHolder;
-import org.apache.stratos.manager.lb.category.*;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.subscription.*;
-import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory;
-import org.apache.stratos.manager.subscription.filter.LBCreationSubscriptionFilter;
-import org.apache.stratos.manager.subscription.filter.SubscriptionFilter;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionMultiTenantBehaviour;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionSingleTenantBehaviour;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils;
-import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
-import org.apache.stratos.manager.utils.ApplicationManagementUtil;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.apache.stratos.manager.utils.RepoPasswordMgtUtil;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.event.tenant.SubscriptionDomainAddedEvent;
-import org.apache.stratos.messaging.event.tenant.SubscriptionDomainRemovedEvent;
-import org.apache.stratos.messaging.util.Util;
-import org.wso2.carbon.context.CarbonContext;
-import org.apache.stratos.manager.publisher.CartridgeSubscriptionDataPublisher;
-
-import java.util.*;
-
-
-/**
- * Manager class for the purpose of managing CartridgeSubscriptionInfo subscriptions, groupings, etc.
- */
-public class CartridgeSubscriptionManager {
-
- private static Log log = LogFactory.getLog(CartridgeSubscriptionManager.class);
- //private static DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-
- public GroupSubscription createGroupSubscription (String groupName, String groupAlias, int tenantId)
- throws GroupSubscriptionException {
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
- GroupSubscription groupSubscription;
-
- try {
- groupSubscription = dataInsertionAndRetrievalMgr.getGroupSubscription(tenantId, groupName, groupAlias);
-
- } catch (PersistenceManagerException e) {
- throw new GroupSubscriptionException(e);
- }
-
- if (groupSubscription != null) {
- // Group Subscription already exists with same Group name and alias
- throw new GroupSubscriptionException("Group Subscription already exists with name [ " + groupName + " ], alias [ " + groupAlias + " ]");
- }
-
- return new GroupSubscription(groupName, groupAlias);
- }
-
- public ApplicationSubscription createApplicationSubscription (String appId, int tenantId) throws ApplicationSubscriptionException {
-
- if (log.isDebugEnabled()) {
- log.debug("create Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
- }
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
- ApplicationSubscription appSubscription;
-
- try {
- appSubscription = dataInsertionAndRetrievalMgr.getApplicationSubscription(tenantId, appId);
-
- } catch (PersistenceManagerException e) {
- log.error("failed to retrieve application Subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e);
- throw new ApplicationSubscriptionException(e);
- }
-
- if (appSubscription != null) {
- // Composite App Subscription already exists with same app id
- log.error("app Id already exists, failed to createappSubscription for appId: " + appId + " and tenantId: " + tenantId);
- throw new ApplicationSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]");
- } else {
-
- if (log.isDebugEnabled()) {
- log.debug("creating new application subscription for app:" + appId );
- }
-
- appSubscription = new ApplicationSubscription(appId);
- // persist
- try {
- this.persistApplicationSubscription(appSubscription);
- } catch (ADCException e) {
- // TODO Auto-generated catch block
- log.error("Failed to persist applicaiton subscription for appId: " + appId +
- " and tenantId: " + tenantId + " e:" + e);
- }
- }
-
- return new ApplicationSubscription(appId);
- }
-
- public void removeApplicationSubscription (String appId, int tenantId) throws ApplicationSubscriptionException {
-
- if (log.isDebugEnabled()) {
- log.debug("remove Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
- }
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
- ApplicationSubscription appSubscription = null;
-
- try {
- appSubscription = dataInsertionAndRetrievalMgr.getApplicationSubscription(tenantId, appId);
-
- } catch (PersistenceManagerException e) {
- log.error("failed to retrieve Application Subscription for appId: " + appId + " and tenantId: " + tenantId + "with exception:" + e);
- throw new ApplicationSubscriptionException(e);
- }
-
- if (appSubscription != null) {
-
- try {
- dataInsertionAndRetrievalMgr.removeApplicationSubscription(tenantId, appId);
- } catch (PersistenceManagerException e) {
- log.error("failed to remove Application Subscription for appId: " + appId + " and tenantId: " + tenantId + " with exception:" + e);
- throw new ApplicationSubscriptionException(e);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("successfully removed Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
- }
-
- }
- }
-
- public ApplicationSubscription getApplicationSubscription (String appId, int tenantId) throws ApplicationSubscriptionException {
- if (log.isDebugEnabled()) {
- log.debug("get Application Subscription for appId: " + appId + " and tenantId: " + tenantId);
- }
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager();
- ApplicationSubscription appSubscription = null;
-
- try {
- appSubscription = dataInsertionAndRetrievalMgr.getApplicationSubscription(tenantId, appId);
-
- } catch (PersistenceManagerException e) {
- log.error("failed to Application Subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e);
- throw new ApplicationSubscriptionException(e);
- }
-
- return appSubscription;
- }
-
- public CartridgeSubscription createCartridgeSubscription (SubscriptionData subscriptionData) throws ADCException,
- InvalidCartridgeAliasException, DuplicateCartridgeAliasException, PolicyException, UnregisteredCartridgeException,
- RepositoryRequiredException, RepositoryCredentialsRequiredException, RepositoryTransportException,
- AlreadySubscribedException, InvalidRepositoryException {
-
-
- CartridgeSubscriptionUtils.validateCartridgeAlias(subscriptionData.getTenantId(), subscriptionData.getCartridgeType(), subscriptionData.getCartridgeAlias());
-
- CartridgeInfo cartridgeInfo;
- try {
- cartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(subscriptionData.getCartridgeType());
-
- } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
- String message = subscriptionData.getCartridgeType() + " is not a valid cartridgeSubscription type. Please try again with a valid cartridgeSubscription type.";
- log.error(message);
- throw new ADCException(message, e);
-
- } catch (Exception e) {
- String message = "Error getting info for " + subscriptionData.getCartridgeType();
- log.error(message, e);
- throw new ADCException(message, e);
- }
-
- // subscribe to relevant service cartridge
- CartridgeSubscription serviceCartridgeSubscription = subscribe (subscriptionData, cartridgeInfo, null);
-
- return serviceCartridgeSubscription;
- }
-
- public void persistCartridgeSubscription (CartridgeSubscription cartridgeSubscription) throws ADCException {
-
- try {
- new DataInsertionAndRetrievalManager().cacheAndPersistSubcription(cartridgeSubscription);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error saving subscription for tenant " +
- cartridgeSubscription.getSubscriber().getTenantDomain() + ", alias " + cartridgeSubscription.getType();
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Successful Subscription: " + cartridgeSubscription.toString());
-
- // Publish tenant subscribed event to message broker
- Set<String> clusterIds = new HashSet<String>();
- clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
- CartridgeSubscriptionUtils.publishTenantSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(),
- cartridgeSubscription.getCartridgeInfo().getType(), clusterIds);
- }
-
- public void persistGroupSubscription (GroupSubscription groupSubscription) throws ADCException {
-
- try {
- new DataInsertionAndRetrievalManager().persistGroupSubscription(groupSubscription);
-
- } catch (PersistenceManagerException e) {
- throw new ADCException(e);
- }
- }
-
- public void persistApplicationSubscription (ApplicationSubscription compositeAppSubscription) throws ADCException {
-
- try {
- new DataInsertionAndRetrievalManager().persistApplicationSubscription(compositeAppSubscription);
-
- } catch (PersistenceManagerException e) {
- throw new ADCException(e);
- }
- }
-
- /**
- *
- * @param subscriptionData
- * @return
- * @throws Exception since the caller doesn't react upon specific exceptions, simply throw Generic Exception class.
- */
- public static SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subscriptionData) throws Exception {
-
- // validate cartridge alias
- CartridgeSubscriptionUtils.validateCartridgeAlias(subscriptionData.getTenantId(), subscriptionData.getCartridgeType(), subscriptionData.getCartridgeAlias());
-
- CartridgeInfo cartridgeInfo;
- try {
- cartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(subscriptionData.getCartridgeType());
-
- } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
- String message = subscriptionData.getCartridgeType() + " is not a valid cartridgeSubscription type. Please try again with a valid cartridgeSubscription type.";
- log.error(message);
- throw new ADCException(message, e);
-
- } catch (Exception e) {
- String message = "Error getting info for " + subscriptionData.getCartridgeType();
- log.error(message, e);
- throw new ADCException(message, e);
- }
-
- // For MT subscriptions check whether there are active instances
- if(cartridgeInfo.getMultiTenant() && !activeInstancesAvailable(subscriptionData)) {
- String msg = "No active instances are found for cartridge [" + subscriptionData.getCartridgeType() + "]";
- log.error(msg);
- throw new ADCException(msg);
- }
-
- // check if this subscription requires Persistence Mapping, and its supported by the cartridge definition
- Properties persistenceMappingProperties = null;
- if (subscriptionData.getPersistanceContext() != null) {
- persistenceMappingProperties = getPersistenceMappingProperties(subscriptionData.getPersistanceContext(), cartridgeInfo);
- }
-
- Properties serviceCartridgeSubscriptionProperties = null;
- Properties propertiesReturnedByFilters = new Properties();
-
- List<SubscriptionFilter> subscriptionFilters = new ArrayList<SubscriptionFilter>();
- subscriptionFilters.add(new LBCreationSubscriptionFilter());
-
- for (SubscriptionFilter subscriptionFilter : subscriptionFilters) {
- // execute filters
- appendProperties(propertiesReturnedByFilters, subscriptionFilter.execute(cartridgeInfo, subscriptionData));
-
- }
-
- // subscribe to relevant service cartridge
- CartridgeSubscription serviceCartridgeSubscription = subscribe (subscriptionData, cartridgeInfo, getLBClusterId(propertiesReturnedByFilters));
-
- if (subscriptionData.getProperties() != null) {
- serviceCartridgeSubscriptionProperties = subscriptionData.getProperties();
- } else {
-
- serviceCartridgeSubscriptionProperties = new Properties();
- }
-
- // add properties returned by filters
- if (propertiesReturnedByFilters.getProperties() != null && propertiesReturnedByFilters.getProperties().length > 0) {
- for (Property prop : propertiesReturnedByFilters.getProperties()) {
-
- serviceCartridgeSubscriptionProperties.addProperty(prop);
- }
- }
-
- // Persistence Mapping related properties
- if (persistenceMappingProperties != null && persistenceMappingProperties.getProperties().length > 0) {
- // add the properties to send to CC via register method
- for (Property persistenceMappingProperty : persistenceMappingProperties.getProperties()) {
- serviceCartridgeSubscriptionProperties.addProperty(persistenceMappingProperty);
- }
- }
-
- // register service cartridge subscription
- return registerCartridgeSubscription(serviceCartridgeSubscription, serviceCartridgeSubscriptionProperties, subscriptionData.getPersistence());
- }
-
- private static String getLBClusterId(Properties propertiesReturnedByFilters) {
- if (propertiesReturnedByFilters != null
- && propertiesReturnedByFilters.getProperties() != null) {
- for (Property prop : propertiesReturnedByFilters.getProperties()) {
- if (prop == null) {
- continue;
- }
- if (prop.getName().equals(CartridgeConstants.LB_CLUSTER_ID)) {
- return String.valueOf(prop.getValue());
- }
- }
- }
- return null;
- }
-
- private static void appendProperties(
- Properties propertiesReturnedByFilters, Properties newProperties) {
-
- if (newProperties.getProperties() == null) {
- return;
- }
- for (Property property : newProperties.getProperties()) {
- if (property != null) {
-
- propertiesReturnedByFilters.addProperty(property);
- }
- }
-
- }
-
- private static boolean activeInstancesAvailable(SubscriptionData subscriptionData) {
- Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(subscriptionData.getCartridgeType());
- if(cluster != null) {
- Collection<Member> members = cluster.getMembers();
- for (Member member : members) {
- if(member.isActive()) {
- if(log.isDebugEnabled()) {
- log.debug("Active member found for cluster [" + cluster +"]");
- }
- return true;
- }
- }
- }
- if(log.isDebugEnabled()) {
- log.debug("Active member not found for cluster [" + cluster +"]");
- }
- return false;
- }
-
-
-
- private static CartridgeSubscription subscribe (SubscriptionData subscriptionData, CartridgeInfo cartridgeInfo, String lbClusterId)
-
- throws ADCException, InvalidCartridgeAliasException,
- DuplicateCartridgeAliasException, PolicyException, UnregisteredCartridgeException, RepositoryRequiredException, RepositoryCredentialsRequiredException,
- RepositoryTransportException, AlreadySubscribedException, InvalidRepositoryException {
-
-
- // Decide tenancy behaviour
- SubscriptionTenancyBehaviour tenancyBehaviour;
- if(cartridgeInfo.getMultiTenant()) {
- tenancyBehaviour = new SubscriptionMultiTenantBehaviour();
- } else {
- tenancyBehaviour = new SubscriptionSingleTenantBehaviour();
- }
-
- // Create the CartridgeSubscription instance
- CartridgeSubscription cartridgeSubscription = CartridgeSubscriptionFactory.getCartridgeSubscriptionInstance(cartridgeInfo, tenancyBehaviour);
-
-
- // For MT cartridges subscription key should not be generated for every subscription,
- // instead use the already generated key at the time of service deployment
- String subscriptionKey = null;
- if(cartridgeInfo.getMultiTenant()) {
- try {
- Service service = new DataInsertionAndRetrievalManager().getService(subscriptionData.getCartridgeType());
- if(service != null) {
- subscriptionKey = service.getSubscriptionKey();
- }else {
- String msg = "Could not find service for cartridge type [" + subscriptionData.getCartridgeType() + "] " ;
- log.error(msg);
- throw new ADCException(msg);
- }
- } catch (Exception e) {
- String msg = "Exception has occurred in get service for cartridge type [" + subscriptionData.getCartridgeType() + "] " ;
- log.error(msg);
- throw new ADCException(msg, e);
- }
- }else {
- // Generate and set the key
- subscriptionKey = CartridgeSubscriptionUtils.generateSubscriptionKey();
-
- }
-
- cartridgeSubscription.setSubscriptionKey(subscriptionKey);
-
- if(log.isDebugEnabled()) {
- log.debug("Repository with url: " + subscriptionData.getRepositoryURL() +
- " username: " + subscriptionData.getRepositoryUsername() +
- " Type: " + subscriptionData.getRepositoryType());
- }
-
- // Create subscriber
- Subscriber subscriber = new Subscriber(subscriptionData.getTenantAdminUsername(), subscriptionData.getTenantId(), subscriptionData.getTenantDomain());
- cartridgeSubscription.setSubscriber(subscriber);
- cartridgeSubscription.setAlias(subscriptionData.getCartridgeAlias());
-
- // Create repository
- Repository repository = cartridgeSubscription.manageRepository(subscriptionData.getRepositoryURL(), subscriptionData.getRepositoryUsername(),
- subscriptionData.getRepositoryPassword(),
- subscriptionData.isPrivateRepository());
-
- // Update repository attributes
- if(repository != null) {
-
- repository.setCommitEnabled(subscriptionData.isCommitsEnabled());
-
- // Encrypt repository password
- String encryptedRepoPassword;
- String repositoryPassword = repository.getPassword();
- if(repositoryPassword != null && !repositoryPassword.isEmpty()) {
- encryptedRepoPassword = RepoPasswordMgtUtil.encryptPassword(repositoryPassword, subscriptionKey);
- } else {
- encryptedRepoPassword = "";
- }
- repository.setPassword(encryptedRepoPassword);
-
- }
-
- // set the LB cluster id relevant to this service cluster
- cartridgeSubscription.setLbClusterId(lbClusterId);
-
- //create subscription
- cartridgeSubscription.createSubscription(subscriber, subscriptionData.getCartridgeAlias(), subscriptionData.getAutoscalingPolicyName(),
- subscriptionData.getDeploymentPolicyName(), repository);
-
- // publishing to bam
- CartridgeSubscriptionDataPublisher.publish(
- subscriptionData.getTenantId(),
- subscriptionData.getTenantAdminUsername(),
- subscriptionData.getCartridgeAlias(),
- subscriptionData.getCartridgeType(),
- subscriptionData.getRepositoryURL(),
- cartridgeInfo.getMultiTenant(),
- subscriptionData.getAutoscalingPolicyName(),
- subscriptionData.getDeploymentPolicyName(),
- cartridgeSubscription.getCluster().getClusterDomain(),
- cartridgeSubscription.getHostName(),
- cartridgeSubscription.getMappedDomain(), "Subscribed");
-
- // Add whether the subscription is enabled upstream git commits
- if(cartridgeSubscription.getPayloadData() != null) {
- cartridgeSubscription.getPayloadData().add(CartridgeConstants.COMMIT_ENABLED, String.valueOf(subscriptionData.isCommitsEnabled()));
- }
-
- if(subscriptionData.getProperties() != null){
- for(Property property : subscriptionData.getProperties().getProperties()){
- if (property.getName().startsWith(CartridgeConstants.CUSTOM_PAYLOAD_PARAM_NAME_PREFIX)) {
- String payloadParamName = property.getName();
- cartridgeSubscription.getPayloadData().add(payloadParamName.substring(
- payloadParamName.indexOf(".") + 1), String.valueOf(property.getValue()));
- }
- }
- }
-
- log.info("Tenant [" + subscriptionData.getTenantId() + "] with username [" + subscriptionData.getTenantAdminUsername() +
- " subscribed to " + "] Cartridge with Alias " + subscriptionData.getCartridgeAlias() + ", Cartridge Type: " +
- subscriptionData.getCartridgeType() + ", Repo URL: " + subscriptionData.getRepositoryURL() + ", Autoscale Policy: " +
- subscriptionData.getAutoscalingPolicyName() + ", Deployment Policy: " + subscriptionData.getDeploymentPolicyName());
-
- return cartridgeSubscription;
- }
-
- /**
- * Registers the cartridge subscription for the given CartridgeSubscriptionInfo object
- *
- * @param cartridgeSubscription CartridgeSubscription subscription
- *
- * @param persistence
- * @return SubscriptionInfo object populated with relevant information
- * @throws ADCException
- * @throws UnregisteredCartridgeException
- */
- public static SubscriptionInfo registerCartridgeSubscription(CartridgeSubscription cartridgeSubscription, Properties properties, Persistence persistence)
- throws ADCException, UnregisteredCartridgeException {
-
- CartridgeSubscriptionInfo cartridgeSubscriptionInfo = cartridgeSubscription.registerSubscription(properties, persistence);
-
- //set status as 'SUBSCRIBED'
- cartridgeSubscription.setSubscriptionStatus(CartridgeConstants.SUBSCRIBED);
-
- try {
- new DataInsertionAndRetrievalManager().cacheAndPersistSubcription(cartridgeSubscription);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error saving subscription for tenant " +
- cartridgeSubscription.getSubscriber().getTenantDomain() + ", alias " + cartridgeSubscription.getType();
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Successful Subscription: " + cartridgeSubscription.toString());
-
- // Publish tenant subscribed event to message broker
- Set<String> clusterIds = new HashSet<String>();
- clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
- CartridgeSubscriptionUtils.publishTenantSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(), cartridgeSubscription.getCartridgeInfo().getType(), clusterIds);
-
- return ApplicationManagementUtil.
- createSubscriptionResponse(cartridgeSubscriptionInfo, cartridgeSubscription.getRepository());
- }
-
- public static void addSubscriptionDomain(int tenantId, String subscriptionAlias, String domainName, String applicationContext)
- throws ADCException {
-
- CartridgeSubscription cartridgeSubscription;
- try {
- cartridgeSubscription = getCartridgeSubscription(tenantId, subscriptionAlias);
- if(cartridgeSubscription == null) {
- throw new ADCException("Cartridge subscription not found");
- }
-
- if(!isSubscriptionDomainValid(domainName)) {
- throw new ADCException(String.format("Domain name %s already registered", domainName));
- }
-
- cartridgeSubscription.addSubscriptionDomain(new SubscriptionDomain(domainName, applicationContext));
- new DataInsertionAndRetrievalManager().cacheAndPersistSubcription(cartridgeSubscription);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Could not add domain to cartridge subscription: [tenant-id] " + tenantId + " [subscription-alias] " + subscriptionAlias +
- " [domain-name] " + domainName + " [application-context] " + applicationContext;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Successfully added domains to cartridge subscription: [tenant-id] " + tenantId + " [subscription-alias] " + subscriptionAlias +
- " [domain-name] " + domainName + " [application-context] " +applicationContext);
-
-
- Set<String> clusterIds = new HashSet<String>();
- clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
- SubscriptionDomainAddedEvent event = new SubscriptionDomainAddedEvent(tenantId, cartridgeSubscription.getType(),
- clusterIds, domainName, applicationContext);
- String topic = Util.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(event);
- }
-
- public static void removeSubscriptionDomain(int tenantId, String subscriptionAlias, String domainName) throws ADCException, DomainSubscriptionDoesNotExist {
-
- CartridgeSubscription cartridgeSubscription;
- try {
- cartridgeSubscription = getCartridgeSubscription(tenantId, subscriptionAlias);
- if(cartridgeSubscription == null) {
- throw new DomainSubscriptionDoesNotExist("Cartridge subscription not found", domainName);
- }
- cartridgeSubscription.removeSubscriptionDomain(domainName);
- new DataInsertionAndRetrievalManager().cacheAndPersistSubcription(cartridgeSubscription);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Could not remove domain from cartridge subscription: [tenant-id] " + tenantId + " [subscription-alias] " + subscriptionAlias +
- " [domain-name] " + domainName;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Successfully removed domain from cartridge subscription: [tenant-id] " + tenantId + " [subscription-alias] " + subscriptionAlias +
- " [domain-name] " + domainName);
-
-
-
- Set<String> clusterIds = new HashSet<String>();
- clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
- SubscriptionDomainRemovedEvent event = new SubscriptionDomainRemovedEvent(tenantId, cartridgeSubscription.getType(),
- clusterIds, domainName);
- String topic = Util.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(event);
- }
-
- public static List<SubscriptionDomain> getSubscriptionDomains(int tenantId, String subscriptionAlias)
- throws ADCException {
-
- try {
- CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(tenantId, subscriptionAlias);
- if(cartridgeSubscription == null) {
- throw new ADCException("Cartridge subscription not found");
- }
-
- //return (List<SubscriptionDomain>) cartridgeSubscription.getSubscriptionDomains();
- return new ArrayList<SubscriptionDomain>(cartridgeSubscription.getSubscriptionDomains());
- } catch (Exception e) {
- String errorMsg = "Could not get domains of cartridge subscription: [tenant-id] " + tenantId + " [subscription-alias] " + subscriptionAlias;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
- }
-
- public static SubscriptionDomain getSubscriptionDomain(int tenantId, String subscriptionAlias, String domain)
- throws ADCException {
-
- try {
- CartridgeSubscription cartridgeSubscription = getCartridgeSubscription(tenantId, subscriptionAlias);
- if(cartridgeSubscription == null) {
- throw new ADCException("Cartridge subscription not found");
- }
-
- return cartridgeSubscription.getSubscriptionDomain(domain);
- } catch (Exception e) {
- String errorMsg = "Could not check [domain] "+domain+" against cartridge subscription: [tenant-id] "
- + tenantId + " [subscription-alias] " + subscriptionAlias;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
- }
-
- public static boolean isSubscriptionDomainValid(String domainName) throws ADCException {
- try {
- if(log.isDebugEnabled()) {
- log.debug(String.format("Validating domain: %s", domainName));
- }
- org.wso2.carbon.user.core.tenant.TenantManager tenantManager = DataHolder.getRealmService().getTenantManager();
- org.wso2.carbon.user.api.Tenant[] tenants = tenantManager.getAllTenants();
- if((tenants != null) && (tenants.length > 0)) {
- DataInsertionAndRetrievalManager manager = new DataInsertionAndRetrievalManager();
- for (org.wso2.carbon.user.api.Tenant tenant : tenants) {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Reading subscriptions for tenant: [tenant-id] %d [tenant-domain] %s",
- tenant.getId(), tenant.getDomain()));
- }
- Collection<CartridgeSubscription> subscriptions = manager.getCartridgeSubscriptions(tenant.getId());
- if (subscriptions == null) {
- continue;
- }
- for (CartridgeSubscription subscription : subscriptions) {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Reading domain names in subscription: [alias] %s [domain-names] %s",
- subscription.getAlias(), subscription.getSubscriptionDomains()));
- }
- if (subscription.subscriptionDomainExists(domainName)) {
- return false;
- }
- }
- }
- }
- if(log.isDebugEnabled()) {
- log.debug(String.format("Domain name %s is valid", domainName));
- }
- return true;
- } catch (Exception e) {
- String errorMsg = "Could not validate domain: " + domainName;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
- }
-
- public static Collection<CartridgeSubscription> getCartridgeSubscriptions (int tenantId, String type) throws ADCException {
-
- if (type == null || type.isEmpty()) {
- return new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(tenantId);
-
- } else {
- return new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(tenantId, type);
- }
- }
-
- public static CartridgeSubscription getCartridgeSubscription (int tenantId, String subscriptionAlias) {
-
- return new DataInsertionAndRetrievalManager().getCartridgeSubscription(tenantId, subscriptionAlias);
- }
-
- /**
- * Unsubscribe from a Cartridge
- *
- * @param tenantDomain Tenant's domain
- * @param alias Alias given at subscription time
- * @throws ADCException
- * @throws NotSubscribedException
- */
- public static void unsubscribeFromCartridge (String tenantDomain, String alias)
- throws ADCException, NotSubscribedException {
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-
- CartridgeSubscription cartridgeSubscription = dataInsertionAndRetrievalManager.getCartridgeSubscription(CarbonContext.getThreadLocalCarbonContext().getTenantId(), alias);
- if(cartridgeSubscription != null) {
- cartridgeSubscription.removeSubscription();
-
- // Remove the information from Topology Model
- // Not needed now. TopologyModel is now changed so that information is taken from subscriptions
- //TopologyClusterInformationModel.getInstance().removeCluster(cartridgeSubscription.getSubscriber().getTenantId(),
- // cartridgeSubscription.getType(), cartridgeSubscription.getAlias());
-
- // remove subscription
- try {
- dataInsertionAndRetrievalManager.removeSubscription(cartridgeSubscription.getSubscriber().getTenantId(), alias);
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error removing subscription for tenant " + tenantDomain + ", alias " + cartridgeSubscription.getAlias();
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- // Publish tenant un-subscribed event to message broker
-
- Set<String> clusterIds = new HashSet<String>();
- clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
- CartridgeSubscriptionUtils.publishTenantUnSubscribedEvent(
- cartridgeSubscription.getSubscriber().getTenantId(),
- cartridgeSubscription.getCartridgeInfo().getType(), clusterIds);
-
- // publishing to the unsubscribed event details to bam
- CartridgeSubscriptionDataPublisher.publish(cartridgeSubscription
- .getSubscriber().getTenantId(), cartridgeSubscription
- .getSubscriber().getAdminUserName(), cartridgeSubscription
- .getAlias(), cartridgeSubscription.getType(),
- "",
- cartridgeSubscription.getCartridgeInfo().getMultiTenant(),
- cartridgeSubscription.getAutoscalingPolicyName(),
- cartridgeSubscription.getDeploymentPolicyName(),
- cartridgeSubscription.getCluster().getClusterDomain(),
- cartridgeSubscription.getHostName(), cartridgeSubscription
- .getMappedDomain(), "unsubscribed");
- }
- else {
- String errorMsg = "No cartridge subscription found with [alias] " + alias + " for [tenant] " + tenantDomain;
- log.error(errorMsg);
- throw new NotSubscribedException(errorMsg, alias);
- }
- }
-
- private static Properties getPersistenceMappingProperties (PersistenceContext persistenceCtxt, CartridgeInfo cartridgeInfo) throws ADCException {
-
- if (!cartridgeInfo.isPersistenceSpecified()) {
- // Persistence Mapping not supported in the cartridge definition - error
- String errorMsg = "Persistence Mapping not supported by the cartridge type " + cartridgeInfo.getType();
- log.error(errorMsg);
- throw new ADCException(errorMsg);
- }
-
- Properties persistenceMappingProperties = new Properties();
- persistenceMappingProperties.setProperties(new Property[]{persistenceCtxt.getPersistanceRequiredProperty(), persistenceCtxt.getSizeProperty(),
- persistenceCtxt.getDeleteOnTerminationProperty(), persistenceCtxt.getVolumeIdProperty()});
-
- return persistenceMappingProperties;
- }
-
- /**
- *
- * Returns a collection of Cartridge subscriptions for a particular tenant and a cartridge type
- *
- * @param tenantId
- * @param cartridgeType
- * @return
- */
- public static Collection<CartridgeSubscription> isCartridgeSubscribed(int tenantId, String cartridgeType) {
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
- return dataInsertionAndRetrievalManager.getCartridgeSubscriptions(tenantId, cartridgeType);
- }
-
- public Collection<CartridgeSubscription> getCartridgeSubscriptionsForType (String cartridgeType) {
-
- return new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(cartridgeType);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynchronizerTaskScheduler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynchronizerTaskScheduler.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynchronizerTaskScheduler.java
new file mode 100644
index 0000000..57530a0
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynchronizerTaskScheduler.java
@@ -0,0 +1,76 @@
+/*
+ * 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.manager.messaging;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.ntask.common.TaskException;
+import org.wso2.carbon.ntask.core.TaskInfo;
+import org.wso2.carbon.ntask.core.TaskManager;
+import org.wso2.carbon.ntask.core.service.TaskService;
+
+import java.util.HashMap;
+
+/**
+ * Tenant synchronizer task scheduler for scheduling the tenant synchronizer task
+ * using carbon task service.
+ */
+public class TenantSynchronizerTaskScheduler {
+
+ private static final Log log = LogFactory.getLog(TenantSynzhronizerTask.class);
+
+ private static final String TENANT_SYNC_TASK_TYPE = "TENANT_SYNC_TASK_TYPE";
+ private static final String TENANT_SYNC_TASK_NAME = "TENANT_SYNC_TASK";
+ private static final String DEFAULT_CRON = "1 * * * * ? *";
+
+ public static void schedule(TaskService taskService) {
+ TaskManager taskManager = null;
+ try {
+
+ if (!taskService.getRegisteredTaskTypes().contains(TENANT_SYNC_TASK_TYPE)) {
+ // Register task type
+ taskService.registerTaskType(TENANT_SYNC_TASK_TYPE);
+
+ // Register task
+ taskManager = taskService.getTaskManager(TENANT_SYNC_TASK_TYPE);
+ TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(DEFAULT_CRON);
+ TaskInfo taskInfo = new TaskInfo(TENANT_SYNC_TASK_NAME,
+ TenantSynzhronizerTask.class.getName(),
+ new HashMap<String, String>(), triggerInfo);
+ taskManager.registerTask(taskInfo);
+ if(log.isDebugEnabled()) {
+ log.debug(String.format("Tenant synchronization task scheduled: %s", TENANT_SYNC_TASK_NAME));
+ }
+ }
+
+ } catch (Exception e) {
+ if (taskManager != null) {
+ try {
+ taskManager.deleteTask(TENANT_SYNC_TASK_NAME);
+ } catch (TaskException te) {
+ if (log.isErrorEnabled()) {
+ log.error(te);
+ }
+ }
+ }
+ throw new RuntimeException(String.format("Could not schedule tenant synchronization task: %s", TENANT_SYNC_TASK_NAME), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynzhronizerTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynzhronizerTask.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynzhronizerTask.java
new file mode 100644
index 0000000..2b354c4
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/TenantSynzhronizerTask.java
@@ -0,0 +1,122 @@
+/*
+ * 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.manager.messaging;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.manager.internal.ServiceReferenceHolder;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.domain.tenant.Tenant;
+import org.apache.stratos.messaging.event.tenant.CompleteTenantEvent;
+import org.apache.stratos.messaging.util.Util;
+import org.wso2.carbon.ntask.core.Task;
+import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
+import org.wso2.carbon.user.core.tenant.TenantManager;
+
+import java.util.*;
+
+/**
+ * Tenant synchronizer task for publishing complete tenant event periodically
+ * to message broker.
+ */
+public class TenantSynzhronizerTask implements Task {
+
+ private static final Log log = LogFactory.getLog(TenantSynzhronizerTask.class);
+
+ @Override
+ public void init() {
+ }
+
+ @Override
+ public void execute() {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Publishing complete tenant event"));
+ }
+ Tenant tenant;
+ List<Tenant> tenants = new ArrayList<Tenant>();
+ TenantManager tenantManager = ServiceReferenceHolder.getRealmService().getTenantManager();
+ org.wso2.carbon.user.api.Tenant[] carbonTenants = tenantManager.getAllTenants();
+ for (org.wso2.carbon.user.api.Tenant carbonTenant : carbonTenants) {
+ // Create tenant
+ if (log.isDebugEnabled()) {
+ log.debug(String.format("Tenant found: [tenant-id] %d [tenant-domain] %s",
+ carbonTenant.getId(), carbonTenant.getDomain()));
+ }
+ tenant = new Tenant(carbonTenant.getId(), carbonTenant.getDomain());
+
+ if (!org.apache.stratos.messaging.message.receiver.tenant.TenantManager.getInstance()
+ .tenantExists(carbonTenant.getId())) {
+ // if the tenant is not already there in TenantManager,
+ // trigger TenantCreatedEvent
+ TenantInfoBean tenantBean = new TenantInfoBean();
+ tenantBean.setTenantId(carbonTenant.getId());
+ tenantBean.setTenantDomain(carbonTenant.getDomain());
+ //TenantMgtUtil.triggerAddTenant(tenantBean);
+ // add tenant to Tenant Manager
+ org.apache.stratos.messaging.message.receiver.tenant.TenantManager.getInstance()
+ .addTenant(tenant);
+ }
+
+ // Add subscriptions
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // List<CartridgeSubscriptionInfo> cartridgeSubscriptions =
+ // PersistenceManager.getSubscriptionsForTenant(tenant.getTenantId());
+ // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Collection<CartridgeSubscription> cartridgeSubscriptions =
+// new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(tenant.getTenantId());
+// if (cartridgeSubscriptions != null && !cartridgeSubscriptions.isEmpty()) {
+// for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
+// if (log.isDebugEnabled()) {
+// log.debug(String.format("Tenant subscription found: [tenant-id] %d [tenant-domain] %s [service] %s",
+// carbonTenant.getId(), carbonTenant.getDomain(),
+// cartridgeSubscription.getType()));
+// }
+// HashSet<String> clusterIds = new HashSet<String>();
+// clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
+// Subscription subscription =
+// new Subscription(
+// cartridgeSubscription.getType(),
+// clusterIds);
+// for (SubscriptionDomain subscriptionDomain : cartridgeSubscription.getSubscriptionDomains()) {
+// subscription.addSubscriptionDomain(subscriptionDomain.getDomainName(),
+// subscriptionDomain.getApplicationContext());
+// }
+// tenant.addSubscription(subscription);
+// }
+// }
+ tenants.add(tenant);
+ }
+ CompleteTenantEvent event = new CompleteTenantEvent(tenants);
+ String topic = Util.getMessageTopicName(event);
+ EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
+ eventPublisher.publish(event);
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not publish complete tenant event", e);
+ }
+ }
+ }
+
+ @Override
+ public void setProperties(Map<String, String> stringStringMap) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/InstanceNotificationPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/InstanceNotificationPublisher.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/InstanceNotificationPublisher.java
new file mode 100644
index 0000000..c82e644
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/messaging/publisher/InstanceNotificationPublisher.java
@@ -0,0 +1,70 @@
+/*
+ * 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.manager.messaging.publisher;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.broker.publish.EventPublisher;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.event.Event;
+import org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent;
+import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupClusterEvent;
+import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupMemberEvent;
+import org.apache.stratos.messaging.util.Util;
+
+/**
+ * Creating the relevant instance notification event and publish it to the
+ * instances.
+ */
+public class InstanceNotificationPublisher {
+ private static final Log log = LogFactory.getLog(InstanceNotificationPublisher.class);
+
+ public InstanceNotificationPublisher() {
+ }
+
+ private void publish(Event event) {
+ String topic = Util.getMessageTopicName(event);
+ EventPublisher depsyncEventPublisher = EventPublisherPool.getPublisher(topic);
+ depsyncEventPublisher.publish(event);
+ }
+
+ /**
+ * Publishing the artifact update event to the instances
+ *
+ * @param clusterId
+ * @param tenantId
+ * @param repoUrl
+ * @param repoUsername
+ * @param repoPassword
+ * @param isCommitEnabled
+ */
+ public void publishArtifactUpdatedEvent(String clusterId, String tenantId, String repoUrl, String repoUsername,
+ String repoPassword, boolean isCommitEnabled) {
+
+ ArtifactUpdatedEvent artifactUpdateEvent = new ArtifactUpdatedEvent();
+ artifactUpdateEvent.setClusterId(clusterId);
+ artifactUpdateEvent.setRepoUserName(repoUsername);
+ artifactUpdateEvent.setRepoPassword(repoPassword);
+ artifactUpdateEvent.setRepoURL(repoUrl);
+ artifactUpdateEvent.setTenantId(tenantId);
+ artifactUpdateEvent.setCommitEnabled(isCommitEnabled);
+
+ publish(artifactUpdateEvent);
+ }
+}
[07/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java
deleted file mode 100644
index 7c78451..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/RegistryBasedPersistenceManager.java
+++ /dev/null
@@ -1,970 +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.manager.persistence;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.registry.RegistryManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.ApplicationSubscription;
-import org.apache.stratos.manager.subscription.GroupSubscription;
-import org.apache.stratos.manager.utils.Deserializer;
-import org.apache.stratos.manager.utils.Serializer;
-import org.wso2.carbon.context.CarbonContext;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-
-public class RegistryBasedPersistenceManager extends PersistenceManager {
-
- private static final Log log = LogFactory.getLog(RegistryBasedPersistenceManager.class);
- // Registry paths
- private static final String STRATOS_MANAGER_REOSURCE = "/stratos_manager";
- private static final String ACTIVE_SUBSCRIPTIONS = "/subscriptions/active";
- private static final String INACTIVE_SUBSCRIPTIONS = "/subscriptions/inactive";
- private static final String SERVICES = "/services";
- private static final String CARTRIDGES = "/cartridges";
- private static final String GROUPS = "/groups";
- private static final String COMPOSITE_APPLICATIONS = "/composite_applications";
- private static final String DEFINITIONS = "/definitions";
- private static final String SERVICE_GROUPING = "/service.grouping";
- private static final String SERVICE_GROUPING_DEFINITIONS = SERVICE_GROUPING + "/definitions";
-
- @Override
- public void persistCartridgeSubscription (CartridgeSubscription cartridgeSubscription) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- persistSubscription(cartridgeSubscription);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- persistSubscription(cartridgeSubscription);
- }
- }
-
- private void persistSubscription (CartridgeSubscription cartridgeSubscription) throws PersistenceManagerException {
-
- // persist
- try {
- RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + CARTRIDGES + "/" +
- Integer.toString(cartridgeSubscription.getSubscriber().getTenantId()) + "/" +
- cartridgeSubscription.getType() + "/" +
- cartridgeSubscription.getAlias(), Serializer.serializeSubscriptionSontextToByteArray(cartridgeSubscription), cartridgeSubscription.getClusterDomain());
-
- if (log.isDebugEnabled()) {
- log.debug("Persisted CartridgeSubscription successfully: [ " + cartridgeSubscription.getSubscriber().getTenantDomain()
- + ", " + cartridgeSubscription.getType() + ", " + cartridgeSubscription.getAlias() + " ] ");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
-
- } catch (IOException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public void removeCartridgeSubscription (int tenantId, String type, String alias) throws PersistenceManagerException {
-
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- removeSubscription(tenantId, type, alias);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- removeSubscription(tenantId, type, alias);
- }
- }
-
- private void removeSubscription (int tenantId, String type, String alias) throws PersistenceManagerException {
-
- // move the subscription from active set to inactive set
- String sourcePath = STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + CARTRIDGES + "/" + Integer.toString(tenantId) + "/" + type + "/" + alias;
- String targetPath = STRATOS_MANAGER_REOSURCE + INACTIVE_SUBSCRIPTIONS + CARTRIDGES + "/" + Integer.toString(tenantId) + "/" + type + "/" + alias;
-
- try {
- RegistryManager.getInstance().move(sourcePath, targetPath);
- if (log.isDebugEnabled()) {
- log.debug("Moved CartridgeSubscription on " + sourcePath + " to " + targetPath + " successfully");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public void persistGroupSubscription(GroupSubscription groupSubscription) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- persistSubscription(tenantId, groupSubscription);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- persistSubscription(tenantId, groupSubscription);
- }
- }
-
- private void persistSubscription (int tenantId, GroupSubscription groupSubscription) throws PersistenceManagerException {
-
- // persist
- try {
- RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + GROUPS + "/" +
- Integer.toString(tenantId) + "/" + groupSubscription.getName() + "/" +
- groupSubscription.getGroupAlias(),
- Serializer.serializeGroupSubscriptionToByteArray(groupSubscription), null);
-
- if (log.isDebugEnabled()) {
- log.debug("Persisted Group Subscription successfully: [ " + groupSubscription.getName() + ", " + groupSubscription.getGroupAlias() + " ] ");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
-
- } catch (IOException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- public GroupSubscription getGroupSubscription (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException {
-
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- return getSubscription(tenantId, groupName, groupAlias);
-
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- return getSubscription(tenantId, groupName, groupAlias);
- }
- }
-
- public GroupSubscription getSubscription (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException {
-
- Object byteObj;
-
- try {
- byteObj = RegistryManager.getInstance().retrieve(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + GROUPS + "/" +
- Integer.toString(tenantId) + "/" + groupName + "/" + groupAlias);
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
-
- if (byteObj == null) {
- return null;
- }
-
- Object groupSubscriptionObj;
-
- try {
- groupSubscriptionObj = Deserializer.deserializeFromByteArray((byte[]) byteObj);
-
- } catch (Exception e) {
- throw new PersistenceManagerException(e);
- }
-
- if (groupSubscriptionObj instanceof GroupSubscription) {
- return (GroupSubscription) groupSubscriptionObj;
- }
-
- return null;
- }
-
- @Override
- public void removeGroupSubscription(int tenantId, String groupName, String groupAlias) throws PersistenceManagerException {
-
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- remove(tenantId, groupName, groupAlias);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- remove(tenantId, groupName, groupAlias);
- }
- }
-
- private void remove (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException {
-
- // move the subscription from active set to inactive set
- String sourcePath = STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + GROUPS + "/" + Integer.toString(tenantId) +
- "/" + groupName + "/" + groupAlias;
- String targetPath = STRATOS_MANAGER_REOSURCE + INACTIVE_SUBSCRIPTIONS + GROUPS + "/" + Integer.toString(tenantId) +
- "/" + groupName + "/" + groupAlias;
-
- try {
- RegistryManager.getInstance().move(sourcePath, targetPath);
- if (log.isDebugEnabled()) {
- log.debug("Moved Group Subscription on " + sourcePath + " to " + targetPath + " successfully");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public Collection<CartridgeSubscription> getCartridgeSubscriptions () throws PersistenceManagerException {
-
- return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + CARTRIDGES);
- }
-
- private Collection<CartridgeSubscription> traverseAndGetCartridgeSubscriptions (String resourcePath) throws PersistenceManagerException {
-
- if (log.isDebugEnabled()) {
- log.debug("Root resource path: " + resourcePath);
- }
-
- Object resourceObj;
-
- try {
- resourceObj = RegistryManager.getInstance().retrieve(resourcePath);
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
-
- Collection<CartridgeSubscription> cartridgeSubscriptions = new ArrayList<CartridgeSubscription>();
-
- if (resourceObj == null) {
- // there is no resource at the given path
- return null;
-
- } else if (resourceObj instanceof String[]) {
-
- // get the paths for all SubscriptionContext instances
- String[] subscriptionResourcePaths = (String[]) resourceObj;
- if (log.isDebugEnabled()) {
- for (String retrievedResourcePath : subscriptionResourcePaths) {
- log.debug("Retrieved resource sub-path " + retrievedResourcePath);
- }
- }
-
- // traverse the paths recursively
- for (String subscriptionResourcePath : subscriptionResourcePaths) {
-
- if (log.isDebugEnabled()) {
- log.debug("Traversing resource path " + subscriptionResourcePath);
- }
-
- Collection<CartridgeSubscription> cartridgeSubscriptionSet = traverseAndGetCartridgeSubscriptions(subscriptionResourcePath);
- if (cartridgeSubscriptionSet != null) {
- cartridgeSubscriptions.addAll(cartridgeSubscriptionSet);
- }
- }
-
- } else {
- // De-serialize
- Object subscriptionObj;
-
- try {
- subscriptionObj = Deserializer.deserializeFromByteArray((byte[]) resourceObj);
-
- } catch (Exception e) {
- // issue might be de-serializing only this object, therefore log and continue without throwing
- log.error("Error while de-serializing the object retrieved from " + resourcePath, e);
- return null;
- }
-
- if (subscriptionObj != null && subscriptionObj instanceof CartridgeSubscription) {
-
- CartridgeSubscription deserilizedCartridgeSubscription = (CartridgeSubscription) subscriptionObj;
- if (log.isDebugEnabled()) {
- log.debug("Successfully de-serialized CartridgeSubscription: " + deserilizedCartridgeSubscription.toString());
- }
-
- //return Collections.singletonList(deserilizedCartridgeSubscription);
- cartridgeSubscriptions.add(deserilizedCartridgeSubscription);
-
- }
- }
-
- // remove any nulls
- cartridgeSubscriptions.removeAll(Collections.singleton(null));
- return cartridgeSubscriptions;
- }
-
- @Override
- public Collection<CartridgeSubscription> getCartridgeSubscriptions (int tenantId) throws PersistenceManagerException {
-
- return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + CARTRIDGES + "/" + Integer.toString(tenantId));
- }
-
- @Override
- public void persistCompositeAppSubscription(ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- persistSubscription(tenantId, compositeAppSubscription);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- persistSubscription(tenantId, compositeAppSubscription);
- }
- }
-
- private void persistSubscription (int tenantId, ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException {
-
- // persist
- try {
- RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + COMPOSITE_APPLICATIONS + "/" +
- Integer.toString(tenantId) + "/" + compositeAppSubscription.getAppId(),
- Serializer.serializeCompositeAppSubscriptionToByteArray(compositeAppSubscription), null);
-
- if (log.isDebugEnabled()) {
- log.debug("Persisted Group Subscription successfully: [ " + compositeAppSubscription.getAppId() + " ] ");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
-
- } catch (IOException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public ApplicationSubscription getCompositeAppSubscription(int tenantId, String compositeAppId) throws PersistenceManagerException {
-
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- return getSubscription(tenantId, compositeAppId);
-
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- return getSubscription(tenantId, compositeAppId);
- }
- }
-
- public ApplicationSubscription getSubscription (int tenantId, String appId) throws PersistenceManagerException {
-
- Object byteObj;
-
- try {
- byteObj = RegistryManager.getInstance().retrieve(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + COMPOSITE_APPLICATIONS + "/" +
- Integer.toString(tenantId) + "/" + appId);
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
-
- if (byteObj == null) {
- return null;
- }
-
- Object compositeAppSubscriptionObj;
-
- try {
- compositeAppSubscriptionObj = Deserializer.deserializeFromByteArray((byte[]) byteObj);
-
- } catch (Exception e) {
- throw new PersistenceManagerException(e);
- }
-
- if (compositeAppSubscriptionObj instanceof ApplicationSubscription) {
- return (ApplicationSubscription) compositeAppSubscriptionObj;
- }
-
- return null;
- }
-
- @Override
- public void removeCompositeAppSubscription(int tenantId, String compositeAppId) throws PersistenceManagerException {
-
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- remove(tenantId, compositeAppId);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- remove(tenantId, compositeAppId);
- }
- }
-
- private void remove (int tenantId, String compositeAppId) throws PersistenceManagerException {
-
- // move the subscription from active set to inactive set
- String sourcePath = STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + COMPOSITE_APPLICATIONS + "/" + Integer.toString(tenantId) +
- "/" + compositeAppId;
- String targetPath = STRATOS_MANAGER_REOSURCE + INACTIVE_SUBSCRIPTIONS + COMPOSITE_APPLICATIONS + "/" + Integer.toString(tenantId) +
- "/" + compositeAppId;
-
- try {
- RegistryManager.getInstance().move(sourcePath, targetPath);
- if (log.isDebugEnabled()) {
- log.debug("Moved Composite App Subscription on " + sourcePath + " to " + targetPath + " successfully");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public void persistService(Service service) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- persistDeployedService(service);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- persistDeployedService(service);
- }
- }
-
- private void persistDeployedService (Service service) throws PersistenceManagerException {
-
- // persist Service
- try {
- RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + SERVICES + "/" + service.getType(),
- Serializer.serializeServiceToByteArray(service), null);
-
- if (log.isDebugEnabled()) {
- log.debug("Persisted Service successfully: [ " + service.getType() + ", " + service.getTenantRange() + " ]");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
-
- } catch (IOException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
-
- @Override
- public Collection<Service> getServices() throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- return traverseAndGetDeloyedServices(STRATOS_MANAGER_REOSURCE + SERVICES);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- return traverseAndGetDeloyedServices(STRATOS_MANAGER_REOSURCE + SERVICES);
- }
- }
-
- @Override
- public Service getService(String cartridgeType) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- return getDeployedService(cartridgeType);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- return getDeployedService(cartridgeType);
- }
- }
-
- public Collection<Service> traverseAndGetDeloyedServices (String resourcePath) throws PersistenceManagerException {
-
- if (log.isDebugEnabled()) {
- log.debug("Root resource path: " + resourcePath);
- }
-
- Object resourceObj;
-
- try {
- resourceObj = RegistryManager.getInstance().retrieve(resourcePath);
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
-
- Collection<Service> services = new ArrayList<Service>();
-
- if (resourceObj == null) {
- // there is no resource at the given path
- return null;
-
- } else if (resourceObj instanceof String[]) {
-
- // get the paths for all Service instances
- String[] serviceResourcePaths = (String[]) resourceObj;
- if (log.isDebugEnabled()) {
- for (String retrievedResourcePath : serviceResourcePaths) {
- log.debug("Retrieved resource sub-path " + retrievedResourcePath);
- }
- }
-
- // traverse the paths recursively
- for (String serviceResourcePath : serviceResourcePaths) {
-
- if (log.isDebugEnabled()) {
- log.debug("Traversing resource path " + serviceResourcePath);
- }
-
- services.addAll(traverseAndGetDeloyedServices(serviceResourcePath));
- }
-
- } else {
- // De-serialize
- Object serviceObj;
-
- try {
- serviceObj = Deserializer.deserializeFromByteArray((byte[]) resourceObj);
-
- } catch (Exception e) {
- // issue might be de-serializing only this object, therefore log and continue without throwing
- log.error("Error while de-serializing the object retrieved from " + resourcePath, e);
- return null;
- }
-
- if (serviceObj != null && serviceObj instanceof Service) {
-
- Service deserilizedService = (Service) serviceObj;
- if (log.isDebugEnabled()) {
- log.debug("Successfully de-serialized Service: " + deserilizedService.toString());
- }
-
- services.add(deserilizedService);
-
- }
- }
-
- // remove any nulls
- services.removeAll(Collections.singleton(null));
- return services;
- }
-
- public Service getDeployedService (String cartridgeType) throws PersistenceManagerException {
-
- Object byteObj;
-
- try {
- byteObj = RegistryManager.getInstance().retrieve(STRATOS_MANAGER_REOSURCE + SERVICES + "/" + cartridgeType);
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
-
- if (byteObj == null) {
- return null;
- }
-
- Object serviceObj;
-
- try {
- serviceObj = Deserializer.deserializeFromByteArray((byte[]) byteObj);
-
- } catch (Exception e) {
- throw new PersistenceManagerException(e);
- }
-
- if (serviceObj instanceof Service) {
- return (Service) serviceObj;
- }
-
- return null;
- }
-
- @Override
- public void removeService(String cartridgeType) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- // TODO: This is only a workaround. Proper fix is to write to tenant registry
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- removeDeployedService(cartridgeType);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- removeDeployedService(cartridgeType);
- }
- }
-
- private void removeDeployedService (String cartridgeType) throws PersistenceManagerException {
-
- String resourcePath = STRATOS_MANAGER_REOSURCE + SERVICES + "/" + cartridgeType;
-
- try {
- RegistryManager.getInstance().delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug("Deleted Service on path " + resourcePath + " successfully");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
-// private void removeCompApplication(String alias) throws PersistenceManagerException {
-//
-// String resourcePath = STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + alias;
-//
-// try {
-// Object obj = RegistryManager.getInstance().retrieve(resourcePath);
-// if (obj != null) {
-// if (log.isDebugEnabled()) {
-// log.debug(" found composite application to remve " + obj + " at resource path " + resourcePath);
-// }
-// }
-// RegistryManager.getInstance().delete(resourcePath);
-// if (log.isDebugEnabled()) {
-// log.debug("Deleted composite application on path " + resourcePath + " successfully");
-// }
-//
-// if (log.isDebugEnabled()) {
-// obj = RegistryManager.getInstance().retrieve(resourcePath);
-// if (obj == null) {
-// log.debug(" veriying that composite application is remvoved, obj is null " + resourcePath);
-// } else {
-// log.debug(" unsuccessful removing composite application " + obj + " at resource path " + resourcePath);
-// }
-// }
-//
-// } catch (RegistryException e) {
-// throw new PersistenceManagerException(e);
-// }
-// }
-
- @Override
- public void persistServiceGroupDefinition(ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException {
-
- // persist Service Group Definition
- try {
- RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + SERVICE_GROUPING_DEFINITIONS + "/" +
- serviceGroupDefinition.getName(),
- Serializer.serializeServiceGroupDefinitionToByteArray(serviceGroupDefinition), null);
-
- if (log.isDebugEnabled()) {
- log.debug("Persisted Service Group Definition successfully: [ " + serviceGroupDefinition.getName() + " ]");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
-
- } catch (IOException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public ServiceGroupDefinition getServiceGroupDefinition(String serviceGroupDefinitionName) throws PersistenceManagerException {
-
- Object byteObj;
-
- try {
- byteObj = RegistryManager.getInstance().retrieve(STRATOS_MANAGER_REOSURCE + SERVICE_GROUPING_DEFINITIONS + "/" +
- serviceGroupDefinitionName);
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
-
- if (byteObj == null) {
- return null;
- }
-
- Object serviceGroupDefinitionObj;
-
- try {
- serviceGroupDefinitionObj = Deserializer.deserializeFromByteArray((byte[]) byteObj);
-
- } catch (Exception e) {
- throw new PersistenceManagerException(e);
- }
-
- if (serviceGroupDefinitionObj instanceof ServiceGroupDefinition) {
- return (ServiceGroupDefinition) serviceGroupDefinitionObj;
- }
-
- return null;
- }
-
- @Override
- public void removeServiceGroupDefinition(String serviceGroupDefinitionName) throws PersistenceManagerException {
-
- String resourcePath = STRATOS_MANAGER_REOSURCE + SERVICE_GROUPING_DEFINITIONS + "/" + serviceGroupDefinitionName;
-
- try {
- RegistryManager.getInstance().delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug("Deleted Service Group Definition on path " + resourcePath + " successfully");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public void createApplication(ApplicationDefinition appDefinition) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- persistApplication(appDefinition);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- persistApplication(appDefinition);
- }
- }
-
- private void persistApplication (ApplicationDefinition appDefinition) throws PersistenceManagerException {
-
- String resourcePath = STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATIONS + "/" + appDefinition.getApplicationId();
-
- try {
- RegistryManager.getInstance().persist(resourcePath,
- Serializer.serializeApplicationDefinitionToByteArray(appDefinition), null);
-
- if (log.isDebugEnabled()) {
- log.debug("Persisted Application Definition successfully: [ " + appDefinition.getApplicationId() + " ]");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
-
- } catch (IOException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
- @Override
- public ApplicationDefinition getApplication(String appId) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- return retrieveApplication(appId);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- return retrieveApplication(appId);
- }
- }
-
- private ApplicationDefinition retrieveApplication (String appId) throws PersistenceManagerException {
-
- Object byteObj;
-
- try {
- byteObj = RegistryManager.getInstance().retrieve(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATIONS + "/" +
- appId);
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
-
- if (byteObj == null) {
- return null;
- }
-
- Object appDefinitionObj;
-
- try {
- appDefinitionObj = Deserializer.deserializeFromByteArray((byte[]) byteObj);
-
- } catch (Exception e) {
- throw new PersistenceManagerException(e);
- }
-
- if (appDefinitionObj instanceof ApplicationDefinition) {
- return (ApplicationDefinition) appDefinitionObj;
- }
-
- return null;
- }
-
- @Override
- public void removeApplication(String appId) throws PersistenceManagerException {
-
- int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
- if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
- carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
-
- deleteApplication(appId);
-
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
-
- } else {
- deleteApplication(appId);
- }
- }
-
- private void deleteApplication (String appId) throws PersistenceManagerException {
-
- String resourcePath = STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATIONS + "/" + appId;
-
- try {
- RegistryManager.getInstance().delete(resourcePath);
- if (log.isDebugEnabled()) {
- log.debug("Deleted Application Definition on path " + resourcePath + " successfully");
- }
-
- } catch (RegistryException e) {
- throw new PersistenceManagerException(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/registry/RegistryManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/registry/RegistryManager.java
new file mode 100644
index 0000000..007a51f
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/persistence/registry/RegistryManager.java
@@ -0,0 +1,207 @@
+/*
+ * 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.manager.persistence.registry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.manager.internal.ServiceReferenceHolder;
+import org.wso2.carbon.registry.core.Resource;
+import org.wso2.carbon.registry.core.exceptions.RegistryException;
+import org.wso2.carbon.registry.core.exceptions.ResourceNotFoundException;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.registry.core.session.UserRegistry;
+
+public class RegistryManager {
+
+ private final static Log log = LogFactory.getLog(RegistryManager.class);
+
+ private static final String STRATOS_MANAGER_REOSURCE = "/stratos_manager";
+
+ private static RegistryService registryService;
+ private static volatile RegistryManager registryManager;
+
+ public static RegistryManager getInstance() {
+
+ if (registryManager == null) {
+ synchronized (RegistryManager.class) {
+ if (registryManager == null) {
+ registryManager = new RegistryManager();
+ }
+ }
+ }
+ return registryManager;
+ }
+
+ private RegistryManager() {
+ registryService = ServiceReferenceHolder.getRegistryService();
+ }
+
+ private UserRegistry initRegistry (int tenantId) throws RegistryException {
+
+ UserRegistry tenantGovRegistry = registryService.getGovernanceSystemRegistry(tenantId);
+
+ // check if the resource is available, else create it
+ if (!tenantGovRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
+ synchronized (RegistryManager.class) {
+ try {
+ if (!tenantGovRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
+ tenantGovRegistry.put(STRATOS_MANAGER_REOSURCE, tenantGovRegistry.newCollection());
+ }
+ } catch (RegistryException e) {
+ String errorMsg = "Failed to create the registry resource " + STRATOS_MANAGER_REOSURCE;
+ log.error(errorMsg, e);
+ throw e;
+ }
+ }
+ }
+
+ return tenantGovRegistry;
+ }
+
+ private UserRegistry initRegistry () throws RegistryException {
+
+ UserRegistry govRegistry = registryService.getGovernanceSystemRegistry();
+
+ // check if the resource is available, else create it
+ if (!govRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
+ synchronized (RegistryManager.class) {
+ try {
+ if (!govRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
+ govRegistry.put(STRATOS_MANAGER_REOSURCE, govRegistry.newCollection());
+ }
+ } catch (RegistryException e) {
+ String errorMsg = "Failed to create the registry resource " + STRATOS_MANAGER_REOSURCE;
+ log.error(errorMsg, e);
+ throw e;
+ }
+ }
+ }
+
+ return govRegistry;
+ }
+
+ public void persist (String path, byte [] resourceBytes, String tag) throws RegistryException {
+
+ UserRegistry registry = initRegistry();
+
+ try {
+ registry.beginTransaction();
+ Resource nodeResource = registry.newResource();
+ nodeResource.setContent(resourceBytes);
+ // store the resource in the registry
+ registry.put(path, nodeResource);
+ if (tag != null) {
+ // apply the tag
+ registry.applyTag(path, tag);
+ }
+ // commit
+ registry.commitTransaction();
+
+ } catch (RegistryException e) {
+ String errorMsg = "Failed to persist the given resource in registry path " + path;
+ log.error(errorMsg, e);
+ // rollback
+ try {
+ registry.rollbackTransaction();
+
+ } catch (RegistryException e1) {
+ errorMsg = "Failed to rollback the transaction in registry path " + path;
+ log.error(errorMsg, e1);
+ throw e1;
+ }
+ throw e;
+ }
+ }
+
+ public void move (String sourcePath, String targetPath) throws RegistryException {
+
+ UserRegistry registry = initRegistry();
+
+ try {
+ registry.beginTransaction();
+ registry.move(sourcePath, targetPath);
+ registry.commitTransaction();
+
+ } catch (RegistryException e) {
+ String errorMsg = "Could not move the resource at "+ sourcePath + " to " + targetPath;
+ log.error(errorMsg, e);
+ // rollback
+ try {
+ registry.rollbackTransaction();
+
+ } catch (RegistryException e1) {
+ errorMsg = "Failed to rollback moving the resource at " + sourcePath + " to " + targetPath;
+ log.error(errorMsg, e1);
+ throw e1;
+ }
+ throw e;
+ }
+ }
+
+ public void delete (String resourcePath) throws RegistryException {
+
+ UserRegistry registry = initRegistry();
+
+ try {
+ registry.beginTransaction();
+ registry.delete(resourcePath);
+ registry.commitTransaction();
+
+ } catch (RegistryException e) {
+ String errorMsg = "Could not delete resource at "+ resourcePath;
+ log.error(errorMsg, e);
+ // rollback
+ try {
+ registry.rollbackTransaction();
+
+ } catch (RegistryException e1) {
+ errorMsg = "Failed to rollback the transaction in registry path " + resourcePath;
+ log.error(errorMsg, e1);
+ throw e1;
+ }
+ throw e;
+ }
+ }
+
+ public Object retrieve (String resourcePath) throws RegistryException {
+
+ UserRegistry registry = initRegistry();
+
+ Resource resource;
+
+ try {
+ resource = registry.get(resourcePath);
+
+ } catch (ResourceNotFoundException ignore) {
+ // nothing has been persisted in the registry yet
+ if(log.isDebugEnabled()) {
+ log.debug("No resource found in the registry path " + resourcePath);
+ }
+ return null;
+
+ } catch (RegistryException e) {
+ String errorMsg = "Failed to retrieve the Resource at " + resourcePath + " from registry.";
+ log.error(errorMsg, e);
+ throw e;
+ }
+
+ return resource.getContent();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/CartridgeSubscriptionDataPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/CartridgeSubscriptionDataPublisher.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/CartridgeSubscriptionDataPublisher.java
deleted file mode 100644
index b851d7a..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/CartridgeSubscriptionDataPublisher.java
+++ /dev/null
@@ -1,176 +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.manager.publisher;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.wso2.carbon.base.ServerConfiguration;
-import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher;
-import org.wso2.carbon.databridge.agent.thrift.exception.AgentException;
-import org.wso2.carbon.databridge.commons.Attribute;
-import org.wso2.carbon.databridge.commons.AttributeType;
-import org.wso2.carbon.databridge.commons.Event;
-import org.wso2.carbon.databridge.commons.StreamDefinition;
-import org.wso2.carbon.utils.CarbonUtils;
-
-/**
- * This will publish the subscription details of tenants to a data receiver.
- * Data is published when a tenant subscribe to a cartridge and when it unsubscribe.
- */
-public class CartridgeSubscriptionDataPublisher {
-
- private static final Log log = LogFactory
- .getLog(CartridgeSubscriptionDataPublisher.class);
- private static AsyncDataPublisher dataPublisher;
- private static StreamDefinition streamDefinition;
- private static final String stratosManagerEventStreamVersion = "1.0.0";
-
- @SuppressWarnings("deprecation")
- public static void publish(int tenantID, String adminUser,
- String cartridgeAlias, String cartridgeType, String repositoryUrl,
- boolean isMultiTenant, String autoScalingPolicy,
- String deploymentPolicy, String clusterID, String hostName,
- String mappedDomain, String action) throws ADCException {
-
- //check if bam is enabled in cartridge-config.properties
- if(! Boolean.parseBoolean(System.getProperty(CartridgeConstants.BAM_PUBLISHER_ENABLED))){
- return;
- }
-
- log.debug(CartridgeConstants.DATA_PUB_TASK_NAME+" cycle started.");
-
- if (dataPublisher == null) {
- createDataPublisher();
-
- // If we cannot create a data publisher we should give up
- // this means data will not be published
- if (dataPublisher == null) {
- log.error("Data Publisher cannot be created or found.");
- return;
- }
- }
-
- //Construct the data to be published
- List<Object> payload = new ArrayList<Object>();
-
- // Payload values
- payload.add(String.valueOf(tenantID));
- payload.add(handleNull(adminUser));
- payload.add(handleNull(cartridgeAlias));
- payload.add(cartridgeType);
- payload.add(handleNull(repositoryUrl));
- payload.add(handleNull(String.valueOf(isMultiTenant)));
- payload.add(handleNull(autoScalingPolicy));
- payload.add(handleNull(deploymentPolicy));
- payload.add(String.valueOf(clusterID));
- payload.add(handleNull(hostName));
- payload.add(handleNull(mappedDomain));
- payload.add(handleNull(action));
-
- Event event = new Event();
- event.setPayloadData(payload.toArray());
- event.setArbitraryDataMap(new HashMap<String, String>());
-
- try {
- if (log.isDebugEnabled()) {
- log.debug(String.format(
- "Publishing BAM event: [stream] %s [version] %s",
- streamDefinition.getName(),
- streamDefinition.getVersion()));
- }
- dataPublisher.publish(streamDefinition.getName(),
- streamDefinition.getVersion(), event);
- } catch (AgentException e) {
- if (log.isErrorEnabled()) {
- log.error(
- String.format(
- "Could not publish BAM event: [stream] %s [version] %s",
- streamDefinition.getName(),
- streamDefinition.getVersion()), e);
- }
- }
- }
-
- private static StreamDefinition initializeStream() throws Exception {
- streamDefinition = new StreamDefinition( CartridgeConstants.STRATOS_MANAGER_EVENT_STREAM,
- stratosManagerEventStreamVersion);
- streamDefinition.setNickName("stratos.manager");
- streamDefinition.setDescription("Tenant Subscription Data");
- // Payload definition
- List<Attribute> payloadData = new ArrayList<Attribute>();
- payloadData.add(new Attribute(CartridgeConstants.TENANT_ID_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.ADMIN_USER_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.CARTRIDGE_ALIAS_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.CARTRIDGE_TYPE_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.REPOSITORY_URL_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.MULTI_TENANT_BEHAVIOR_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.AUTO_SCALE_POLICY_COL, AttributeType.STRING));
- payloadData
- .add(new Attribute(CartridgeConstants.DEPLOYMENT_POLICY_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.CLUSTER_ID_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.HOST_NAME_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.MAPPED_DOMAIN_COL, AttributeType.STRING));
- payloadData.add(new Attribute(CartridgeConstants.ACTION_COL, AttributeType.STRING));
- streamDefinition.setPayloadData(payloadData);
- return streamDefinition;
- }
-
- private static void createDataPublisher() throws ADCException {
- // creating the agent
- ServerConfiguration serverConfig = CarbonUtils.getServerConfiguration();
- String trustStorePath = serverConfig.getFirstProperty("Security.TrustStore.Location");
- String trustStorePassword = serverConfig.getFirstProperty("Security.TrustStore.Password");
-
- //value is in the carbon.xml file and should be set to the thrift port of BAM
- String bamServerUrl = serverConfig.getFirstProperty("BamServerURL");
-
- //getting the BAM related values from cartridge-config.properties
- String adminUsername = System.getProperty(CartridgeConstants.BAM_ADMIN_USERNAME);
- String adminPassword = System.getProperty(CartridgeConstants.BAM_ADMIN_PASSWORD);
-
- System.setProperty("javax.net.ssl.trustStore", trustStorePath);
- System.setProperty("javax.net.ssl.trustStorePassword",
- trustStorePassword);
-
- try {
- dataPublisher = new AsyncDataPublisher(
- "tcp://" + bamServerUrl + "", adminUsername, adminPassword);
- initializeStream();
- dataPublisher.addStreamDefinition(streamDefinition);
- } catch (Exception e) {
- String msg = "Unable to create a data publisher to "+ bamServerUrl;
- log.error(msg, e);
- throw new ADCException(msg, e);
- }
- }
-
- private static String handleNull(String val) {
- if (val == null) {
- return "";
- }
- return val;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/InstanceNotificationPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/InstanceNotificationPublisher.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/InstanceNotificationPublisher.java
deleted file mode 100644
index aba3cf9..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/InstanceNotificationPublisher.java
+++ /dev/null
@@ -1,86 +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.manager.publisher;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent;
-import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupClusterEvent;
-import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupMemberEvent;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * Creating the relevant instance notification event and publish it to the
- * instances.
- */
-public class InstanceNotificationPublisher {
- private static final Log log = LogFactory.getLog(InstanceNotificationPublisher.class);
-
- public InstanceNotificationPublisher() {
- }
-
- private void publish(Event event) {
- String topic = Util.getMessageTopicName(event);
- EventPublisher depsyncEventPublisher = EventPublisherPool.getPublisher(topic);
- depsyncEventPublisher.publish(event);
- }
-
- /**
- * Publishing the artifact update event to the instances
- *
- * @param clusterId
- * @param tenantId
- * @param repoUrl
- * @param repoUsername
- * @param repoPassword
- * @param isCommitEnabled
- */
- public void publishArtifactUpdatedEvent(String clusterId, String tenantId, String repoUrl, String repoUsername,
- String repoPassword, boolean isCommitEnabled) {
-
- ArtifactUpdatedEvent artifactUpdateEvent = new ArtifactUpdatedEvent();
- artifactUpdateEvent.setClusterId(clusterId);
- artifactUpdateEvent.setRepoUserName(repoUsername);
- artifactUpdateEvent.setRepoPassword(repoPassword);
- artifactUpdateEvent.setRepoURL(repoUrl);
- artifactUpdateEvent.setTenantId(tenantId);
- artifactUpdateEvent.setCommitEnabled(isCommitEnabled);
-
- publish(artifactUpdateEvent);
- }
-
- /**
- * Publishing the instance termination notification to the instances
- *
- * @param memberId
- */
- public void sendInstanceCleanupEventForMember(String memberId) {
- log.info(String.format("Publishing Instance Cleanup Event: [member] %s", memberId));
- publish(new InstanceCleanupMemberEvent(memberId));
- }
-
- public void sendInstanceCleanupEventForCluster(String clusterId) {
- log.info(String.format("Publishing Instance Cleanup Event: [cluster] %s", clusterId));
- publish(new InstanceCleanupClusterEvent(clusterId, null));
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantEventPublisher.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantEventPublisher.java
deleted file mode 100644
index 4201ee3..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantEventPublisher.java
+++ /dev/null
@@ -1,124 +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.manager.publisher;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.beans.TenantInfoBean;
-import org.apache.stratos.common.exception.ApacheStratosException;
-import org.apache.stratos.common.listeners.TenantMgtListener;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.tenant.Tenant;
-import org.apache.stratos.messaging.event.tenant.TenantCreatedEvent;
-import org.apache.stratos.messaging.event.tenant.TenantRemovedEvent;
-import org.apache.stratos.messaging.event.tenant.TenantUpdatedEvent;
-import org.apache.stratos.messaging.util.Util;
-
-/**
- * Tenant event publisher to publish tenant events to the message broker by
- * listening to the tenant manager.
- */
-public class TenantEventPublisher implements TenantMgtListener {
-
- private static final Log log = LogFactory.getLog(TenantEventPublisher.class);
- private static final int EXEC_ORDER = 1;
-
- @Override
- public void onTenantCreate(TenantInfoBean tenantInfo) throws ApacheStratosException {
- try {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Publishing tenant created event: [tenant-id] %d [tenant-domain] %s",
- tenantInfo.getTenantId(), tenantInfo.getTenantDomain()));
- }
- Tenant tenant = new Tenant(tenantInfo.getTenantId(), tenantInfo.getTenantDomain());
- TenantCreatedEvent event = new TenantCreatedEvent(tenant);
- String topic = Util.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(event);
- } catch (Exception e) {
- log.error(String.format("Could not publish tenant created event [tenant-id] %d [tenant-domain] %s ",
- tenantInfo.getTenantId(),
- tenantInfo.getTenantDomain()), e);
- }
- }
-
- @Override
- public void onTenantUpdate(TenantInfoBean tenantInfo) throws ApacheStratosException {
- try {
- if (log.isInfoEnabled()) {
- log.info(String.format("Publishing tenant updated event: [tenant-id] %d [tenant-domain] %s",
- tenantInfo.getTenantId(), tenantInfo.getTenantDomain()));
- }
- TenantUpdatedEvent event =
- new TenantUpdatedEvent(tenantInfo.getTenantId(),
- tenantInfo.getTenantDomain());
- String topic = Util.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(event);
- } catch (Exception e) {
- log.error(String.format("Could not publish tenant updated event:[tenant-id] %d [tenant-domain] %s ",
- tenantInfo.getTenantId(),
- tenantInfo.getTenantDomain()), e);
- }
- }
-
- @Override
- public void onTenantDelete(int tenantId) {
- try {
- if (log.isInfoEnabled()) {
- log.info(String.format("Publishing tenant removed event: [tenant-id] %d", tenantId));
- }
- TenantRemovedEvent event = new TenantRemovedEvent(tenantId);
- String topic = Util.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(event);
- } catch (Exception e) {
- log.error(String.format("Could not publish tenant removed event [tenant-id] %d", tenantId),e);
- }
- }
-
- @Override
- public void onTenantRename(int tenantId, String oldDomainName, String newDomainName)
- throws ApacheStratosException {
- }
-
- @Override
- public void onTenantInitialActivation(int tenantId) throws ApacheStratosException {
- }
-
- @Override
- public void onTenantActivation(int tenantId) throws ApacheStratosException {
- }
-
- @Override
- public void onTenantDeactivation(int tenantId) throws ApacheStratosException {
- }
-
- @Override
- public void onSubscriptionPlanChange(int tenantId, String oldPlan, String newPlan)
- throws ApacheStratosException {
- }
-
- @Override
- public int getListenerOrder() {
- return EXEC_ORDER;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynchronizerTaskScheduler.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynchronizerTaskScheduler.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynchronizerTaskScheduler.java
deleted file mode 100644
index f97b897..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynchronizerTaskScheduler.java
+++ /dev/null
@@ -1,76 +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.manager.publisher;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.ntask.common.TaskException;
-import org.wso2.carbon.ntask.core.TaskInfo;
-import org.wso2.carbon.ntask.core.TaskManager;
-import org.wso2.carbon.ntask.core.service.TaskService;
-
-import java.util.HashMap;
-
-/**
- * Tenant synchronizer task scheduler for scheduling the tenant synchronizer task
- * using carbon task service.
- */
-public class TenantSynchronizerTaskScheduler {
-
- private static final Log log = LogFactory.getLog(TenantSynzhronizerTask.class);
-
- private static final String TENANT_SYNC_TASK_TYPE = "TENANT_SYNC_TASK_TYPE";
- private static final String TENANT_SYNC_TASK_NAME = "TENANT_SYNC_TASK";
- private static final String DEFAULT_CRON = "1 * * * * ? *";
-
- public static void schedule(TaskService taskService) {
- TaskManager taskManager = null;
- try {
-
- if (!taskService.getRegisteredTaskTypes().contains(TENANT_SYNC_TASK_TYPE)) {
- // Register task type
- taskService.registerTaskType(TENANT_SYNC_TASK_TYPE);
-
- // Register task
- taskManager = taskService.getTaskManager(TENANT_SYNC_TASK_TYPE);
- TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(DEFAULT_CRON);
- TaskInfo taskInfo = new TaskInfo(TENANT_SYNC_TASK_NAME,
- TenantSynzhronizerTask.class.getName(),
- new HashMap<String, String>(), triggerInfo);
- taskManager.registerTask(taskInfo);
- if(log.isDebugEnabled()) {
- log.debug(String.format("Tenant synchronization task scheduled: %s", TENANT_SYNC_TASK_NAME));
- }
- }
-
- } catch (Exception e) {
- if (taskManager != null) {
- try {
- taskManager.deleteTask(TENANT_SYNC_TASK_NAME);
- } catch (TaskException te) {
- if (log.isErrorEnabled()) {
- log.error(te);
- }
- }
- }
- throw new RuntimeException(String.format("Could not schedule tenant synchronization task: %s", TENANT_SYNC_TASK_NAME), e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java
deleted file mode 100644
index 564e675..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java
+++ /dev/null
@@ -1,126 +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.manager.publisher;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.internal.DataHolder;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.SubscriptionDomain;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.domain.tenant.Subscription;
-import org.apache.stratos.messaging.domain.tenant.Tenant;
-import org.apache.stratos.messaging.event.tenant.CompleteTenantEvent;
-import org.apache.stratos.messaging.util.Util;
-import org.wso2.carbon.ntask.core.Task;
-import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-
-import java.util.*;
-
-/**
- * Tenant synchronizer task for publishing complete tenant event periodically
- * to message broker.
- */
-public class TenantSynzhronizerTask implements Task {
-
- private static final Log log = LogFactory.getLog(TenantSynzhronizerTask.class);
-
- @Override
- public void init() {
- }
-
- @Override
- public void execute() {
- try {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Publishing complete tenant event"));
- }
- Tenant tenant;
- List<Tenant> tenants = new ArrayList<Tenant>();
- TenantManager tenantManager = DataHolder.getRealmService().getTenantManager();
- org.wso2.carbon.user.api.Tenant[] carbonTenants = tenantManager.getAllTenants();
- for (org.wso2.carbon.user.api.Tenant carbonTenant : carbonTenants) {
- // Create tenant
- if (log.isDebugEnabled()) {
- log.debug(String.format("Tenant found: [tenant-id] %d [tenant-domain] %s",
- carbonTenant.getId(), carbonTenant.getDomain()));
- }
- tenant = new Tenant(carbonTenant.getId(), carbonTenant.getDomain());
-
- if (!org.apache.stratos.messaging.message.receiver.tenant.TenantManager.getInstance()
- .tenantExists(carbonTenant.getId())) {
- // if the tenant is not already there in TenantManager,
- // trigger TenantCreatedEvent
- TenantInfoBean tenantBean = new TenantInfoBean();
- tenantBean.setTenantId(carbonTenant.getId());
- tenantBean.setTenantDomain(carbonTenant.getDomain());
- //TenantMgtUtil.triggerAddTenant(tenantBean);
- // add tenant to Tenant Manager
- org.apache.stratos.messaging.message.receiver.tenant.TenantManager.getInstance()
- .addTenant(tenant);
- }
-
- // Add subscriptions
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // List<CartridgeSubscriptionInfo> cartridgeSubscriptions =
- // PersistenceManager.getSubscriptionsForTenant(tenant.getTenantId());
- // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- Collection<CartridgeSubscription> cartridgeSubscriptions =
- new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(tenant.getTenantId());
- if (cartridgeSubscriptions != null && !cartridgeSubscriptions.isEmpty()) {
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- if (log.isDebugEnabled()) {
- log.debug(String.format("Tenant subscription found: [tenant-id] %d [tenant-domain] %s [service] %s",
- carbonTenant.getId(), carbonTenant.getDomain(),
- cartridgeSubscription.getType()));
- }
- HashSet<String> clusterIds = new HashSet<String>();
- clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain());
- Subscription subscription =
- new Subscription(
- cartridgeSubscription.getType(),
- clusterIds);
- for (SubscriptionDomain subscriptionDomain : cartridgeSubscription.getSubscriptionDomains()) {
- subscription.addSubscriptionDomain(subscriptionDomain.getDomainName(),
- subscriptionDomain.getApplicationContext());
- }
- tenant.addSubscription(subscription);
- }
- }
- tenants.add(tenant);
- }
- CompleteTenantEvent event = new CompleteTenantEvent(tenants);
- String topic = Util.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(event);
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Could not publish complete tenant event", e);
- }
- }
- }
-
- @Override
- public void setProperties(Map<String, String> stringStringMap) {
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/registry/RegistryManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/registry/RegistryManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/registry/RegistryManager.java
deleted file mode 100644
index c2ff327..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/registry/RegistryManager.java
+++ /dev/null
@@ -1,207 +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.manager.registry;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.internal.DataHolder;
-import org.wso2.carbon.registry.core.Resource;
-import org.wso2.carbon.registry.core.exceptions.RegistryException;
-import org.wso2.carbon.registry.core.exceptions.ResourceNotFoundException;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-
-public class RegistryManager {
-
- private final static Log log = LogFactory.getLog(RegistryManager.class);
-
- private static final String STRATOS_MANAGER_REOSURCE = "/stratos_manager";
-
- private static RegistryService registryService;
- private static volatile RegistryManager registryManager;
-
- public static RegistryManager getInstance() {
-
- if (registryManager == null) {
- synchronized (RegistryManager.class) {
- if (registryManager == null) {
- registryManager = new RegistryManager();
- }
- }
- }
- return registryManager;
- }
-
- private RegistryManager() {
- registryService = DataHolder.getRegistryService();
- }
-
- private UserRegistry initRegistry (int tenantId) throws RegistryException {
-
- UserRegistry tenantGovRegistry = registryService.getGovernanceSystemRegistry(tenantId);
-
- // check if the resource is available, else create it
- if (!tenantGovRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
- synchronized (RegistryManager.class) {
- try {
- if (!tenantGovRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
- tenantGovRegistry.put(STRATOS_MANAGER_REOSURCE, tenantGovRegistry.newCollection());
- }
- } catch (RegistryException e) {
- String errorMsg = "Failed to create the registry resource " + STRATOS_MANAGER_REOSURCE;
- log.error(errorMsg, e);
- throw e;
- }
- }
- }
-
- return tenantGovRegistry;
- }
-
- private UserRegistry initRegistry () throws RegistryException {
-
- UserRegistry govRegistry = registryService.getGovernanceSystemRegistry();
-
- // check if the resource is available, else create it
- if (!govRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
- synchronized (RegistryManager.class) {
- try {
- if (!govRegistry.resourceExists(STRATOS_MANAGER_REOSURCE)) {
- govRegistry.put(STRATOS_MANAGER_REOSURCE, govRegistry.newCollection());
- }
- } catch (RegistryException e) {
- String errorMsg = "Failed to create the registry resource " + STRATOS_MANAGER_REOSURCE;
- log.error(errorMsg, e);
- throw e;
- }
- }
- }
-
- return govRegistry;
- }
-
- public void persist (String path, byte [] resourceBytes, String tag) throws RegistryException {
-
- UserRegistry registry = initRegistry();
-
- try {
- registry.beginTransaction();
- Resource nodeResource = registry.newResource();
- nodeResource.setContent(resourceBytes);
- // store the resource in the registry
- registry.put(path, nodeResource);
- if (tag != null) {
- // apply the tag
- registry.applyTag(path, tag);
- }
- // commit
- registry.commitTransaction();
-
- } catch (RegistryException e) {
- String errorMsg = "Failed to persist the given resource in registry path " + path;
- log.error(errorMsg, e);
- // rollback
- try {
- registry.rollbackTransaction();
-
- } catch (RegistryException e1) {
- errorMsg = "Failed to rollback the transaction in registry path " + path;
- log.error(errorMsg, e1);
- throw e1;
- }
- throw e;
- }
- }
-
- public void move (String sourcePath, String targetPath) throws RegistryException {
-
- UserRegistry registry = initRegistry();
-
- try {
- registry.beginTransaction();
- registry.move(sourcePath, targetPath);
- registry.commitTransaction();
-
- } catch (RegistryException e) {
- String errorMsg = "Could not move the resource at "+ sourcePath + " to " + targetPath;
- log.error(errorMsg, e);
- // rollback
- try {
- registry.rollbackTransaction();
-
- } catch (RegistryException e1) {
- errorMsg = "Failed to rollback moving the resource at " + sourcePath + " to " + targetPath;
- log.error(errorMsg, e1);
- throw e1;
- }
- throw e;
- }
- }
-
- public void delete (String resourcePath) throws RegistryException {
-
- UserRegistry registry = initRegistry();
-
- try {
- registry.beginTransaction();
- registry.delete(resourcePath);
- registry.commitTransaction();
-
- } catch (RegistryException e) {
- String errorMsg = "Could not delete resource at "+ resourcePath;
- log.error(errorMsg, e);
- // rollback
- try {
- registry.rollbackTransaction();
-
- } catch (RegistryException e1) {
- errorMsg = "Failed to rollback the transaction in registry path " + resourcePath;
- log.error(errorMsg, e1);
- throw e1;
- }
- throw e;
- }
- }
-
- public Object retrieve (String resourcePath) throws RegistryException {
-
- UserRegistry registry = initRegistry();
-
- Resource resource;
-
- try {
- resource = registry.get(resourcePath);
-
- } catch (ResourceNotFoundException ignore) {
- // nothing has been persisted in the registry yet
- if(log.isDebugEnabled()) {
- log.debug("No resource found in the registry path " + resourcePath);
- }
- return null;
-
- } catch (RegistryException e) {
- String errorMsg = "Failed to retrieve the Resource at " + resourcePath + " from registry.";
- log.error(errorMsg, e);
- throw e;
- }
-
- return resource.getContent();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/Repository.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/Repository.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/Repository.java
deleted file mode 100644
index ab95ae3..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/repository/Repository.java
+++ /dev/null
@@ -1,87 +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.manager.repository;
-
-import java.io.Serializable;
-
-public class Repository implements Serializable {
-
- private static final long serialVersionUID = 8386330511938705573L;
- private int id;
- private String url;
- private String userName;
- private String password;
- private boolean isPrivateRepository;
- private boolean commitEnabled;
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public boolean isPrivateRepository() {
- return isPrivateRepository;
- }
-
- public void setPrivateRepository(boolean privateRepository) {
- isPrivateRepository = privateRepository;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- return "Repository [id=" + id + ", url=" + url + ", userName=" + userName +
- ", isPrivateRepository=" + isPrivateRepository + "]";
- }
-
- public boolean isCommitEnabled() {
- return commitEnabled;
- }
-
- public void setCommitEnabled(boolean commitEnabled) {
- this.commitEnabled = commitEnabled;
- }
-}
[05/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionData.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionData.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionData.java
deleted file mode 100644
index 23fd891..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionData.java
+++ /dev/null
@@ -1,217 +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.manager.subscription;
-
-
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * This holds the data that are gathered at the time of subscription. This is usefull when passing subscription details to the method calls.
- */
-public class SubscriptionData {
-
- private String cartridgeType;
- private String cartridgeAlias;
- private String autoscalingPolicyName;
- private String deploymentPolicyName;
- private String tenantDomain;
- private int tenantId;
- private String tenantAdminUsername;
- private String repositoryType = "git";
- private String repositoryURL;
- private boolean isPrivateRepository;
- private String repositoryUsername;
- private String repositoryPassword;
- private PersistenceContext persistanceCtxt;
- private boolean isCommitsEnabled;
- private String serviceGroup;
- private Set<String> domains;
- private Persistence persistence;
- private Properties properties;
- private String serviceName;
-
- public SubscriptionData() {
- this.domains = new HashSet<String>();
- }
-
- public String getCartridgeType() {
- return cartridgeType;
- }
-
- public void setCartridgeType(String cartridgeType) {
- this.cartridgeType = cartridgeType;
- }
-
- public String getCartridgeAlias() {
- return cartridgeAlias;
- }
-
- public void setCartridgeAlias(String cartridgeAlias) {
- this.cartridgeAlias = cartridgeAlias;
- }
-
- public String getAutoscalingPolicyName() {
- return autoscalingPolicyName;
- }
-
- public void setAutoscalingPolicyName(String autoscalingPolicyName) {
- this.autoscalingPolicyName = autoscalingPolicyName;
- }
-
- public String getDeploymentPolicyName() {
- return deploymentPolicyName;
- }
-
- public void setDeploymentPolicyName(String deploymentPolicyName) {
- this.deploymentPolicyName = deploymentPolicyName;
- }
-
- public String getTenantDomain() {
- return tenantDomain;
- }
-
- public void setTenantDomain(String tenantDomain) {
- this.tenantDomain = tenantDomain;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getTenantAdminUsername() {
- return tenantAdminUsername;
- }
-
- public void setTenantAdminUsername(String tenantAdminUsername) {
- this.tenantAdminUsername = tenantAdminUsername;
- }
-
- public String getRepositoryType() {
- return repositoryType;
- }
-
- public void setRepositoryType(String repositoryType) {
- this.repositoryType = repositoryType;
- }
-
- public String getRepositoryURL() {
- return repositoryURL;
- }
-
- public void setRepositoryURL(String repositoryURL) {
- this.repositoryURL = repositoryURL;
- }
-
- public boolean isPrivateRepository() {
- return isPrivateRepository;
- }
-
- public void setPrivateRepository(boolean isPrivateRepository) {
- this.isPrivateRepository = isPrivateRepository;
- }
-
- public String getRepositoryUsername() {
- return repositoryUsername;
- }
-
- public void setRepositoryUsername(String repositoryUsername) {
- this.repositoryUsername = repositoryUsername;
- }
-
- public String getRepositoryPassword() {
- return repositoryPassword;
- }
-
- public void setRepositoryPassword(String repositoryPassword) {
- this.repositoryPassword = repositoryPassword;
- }
-
- public PersistenceContext getPersistanceContext() {
- return persistanceCtxt;
- }
-
- public void setPersistanceCtxt(PersistenceContext persistanceCtxt) {
- this.persistanceCtxt = persistanceCtxt;
- }
-
- public boolean isCommitsEnabled() {
- return isCommitsEnabled;
- }
-
- public void setCommitsEnabled(boolean isCommitsEnabled) {
- this.isCommitsEnabled = isCommitsEnabled;
- }
-
- public String getServiceGroup() {
- return serviceGroup;
- }
-
- public void setServiceGroup(String serviceGroup) {
- this.serviceGroup = serviceGroup;
- }
-
- public void addDomains(Set<String> domains) {
- domains.addAll(domains);
- }
-
- public void removeDomain(String domain) {
- domains.remove(domain);
- }
-
- public void removeDomains(Set<String> domains) {
- domains.removeAll(domains);
- }
-
- public Set<String> getDomains() {
- return Collections.unmodifiableSet(domains);
- }
-
- public Persistence getPersistence() {
- return persistence;
- }
-
- public void setPersistence(Persistence persistence) {
- this.persistence = persistence;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionDomain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionDomain.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionDomain.java
deleted file mode 100644
index 9fed0b0..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionDomain.java
+++ /dev/null
@@ -1,48 +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.manager.subscription;
-
-import java.io.Serializable;
-
-/**
- * Subscription domain definition.
- */
-public class SubscriptionDomain implements Serializable{
- private final String domainName;
- private final String applicationContext;
-
- public SubscriptionDomain(String domainName, String applicationContext) {
- this.domainName = domainName;
- this.applicationContext = applicationContext;
- }
-
- public String getDomainName() {
- return domainName;
- }
-
- public String getApplicationContext() {
- return applicationContext;
- }
-
- @Override
- public String toString() {
- return String.format("[domain-name] %s [application-context] %s", getDomainName(), getApplicationContext());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCache.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCache.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCache.java
deleted file mode 100644
index ce51511..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCache.java
+++ /dev/null
@@ -1,119 +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.manager.subscription.cache;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class CartridgeInstanceCache {
-
- private static final Log log = LogFactory.getLog(CartridgeInstanceCache.class);
-
- private Map<CartridgeInstanceCacheKey, CartridgeSubscription> cartridgeInstanceKeyToCartridgeInstance;
- private final Map<Integer, List<CartridgeSubscription>> tenantIdToCartridgeInstance;
-
- private static CartridgeInstanceCache cartridgeInstanceCache;
-
- private CartridgeInstanceCache() {
- cartridgeInstanceKeyToCartridgeInstance = new ConcurrentHashMap<CartridgeInstanceCacheKey,
- CartridgeSubscription>();
- tenantIdToCartridgeInstance = new ConcurrentHashMap<Integer, List<CartridgeSubscription>>();
- }
-
- public static CartridgeInstanceCache getCartridgeInstanceCache() {
-
- if (cartridgeInstanceCache == null) {
- synchronized(CartridgeInstanceCache.class) {
- if (cartridgeInstanceCache == null) {
- cartridgeInstanceCache = new CartridgeInstanceCache();
- }
- }
- }
- return cartridgeInstanceCache;
- }
-
- public void addCartridgeInstances (int tenantId, List<CartridgeSubscription> cartridgeSubscriptions) {
-
- //tenantIdToCartridgeInstance.putSubscription(tenantId, cartridgeSubscriptions);
- for(CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- addCartridgeInstance(new CartridgeInstanceCacheKey(tenantId, cartridgeSubscription.getAlias()),
- cartridgeSubscription);
- }
- }
-
- public void addCartridgeInstance(CartridgeInstanceCacheKey cartridgeInstanceCacheKey,
- CartridgeSubscription cartridgeSubscription) {
-
- cartridgeInstanceKeyToCartridgeInstance.put(cartridgeInstanceCacheKey, cartridgeSubscription);
-
- List<CartridgeSubscription> cartridgeSubscriptions = tenantIdToCartridgeInstance.get(cartridgeInstanceCacheKey.
- getTenantId());
- if(cartridgeSubscriptions != null) {
- cartridgeSubscriptions.add(cartridgeSubscription);
- }
- else {
- cartridgeSubscriptions = new Vector<CartridgeSubscription>();
- cartridgeSubscriptions.add(cartridgeSubscription);
- tenantIdToCartridgeInstance.put(cartridgeInstanceCacheKey.getTenantId(), cartridgeSubscriptions);
- }
-
- log.info("Added tenant " + cartridgeInstanceCacheKey.getTenantId() + "'s cartridge subscription with alias " +
- cartridgeInstanceCacheKey.getCartridgeInstanceAlias() + " to the cache");
- }
-
- public CartridgeSubscription getCartridgeInstance (CartridgeInstanceCacheKey cartridgeInstanceCacheKey) {
-
- return cartridgeInstanceKeyToCartridgeInstance.get(cartridgeInstanceCacheKey);
- }
-
- public List<CartridgeSubscription> getCartridgeInstances (int tenantId) {
-
- return tenantIdToCartridgeInstance.get(tenantId);
- }
-
- public boolean alreadyExists (CartridgeInstanceCacheKey cartridgeInstanceCacheKey) {
-
- return cartridgeInstanceKeyToCartridgeInstance.containsKey(cartridgeInstanceCacheKey);
- }
-
- public void removeCartridgeInstances (int tenantId) {
-
- List<CartridgeSubscription> cartridgeSubscriptions = tenantIdToCartridgeInstance.get(tenantId);
- for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
- removeCartridgeInstance(new CartridgeInstanceCacheKey(tenantId, cartridgeSubscription.getAlias()));
- }
- }
-
- public void removeCartridgeInstance (CartridgeInstanceCacheKey cartridgeInstanceCacheKey) {
-
- if (cartridgeInstanceKeyToCartridgeInstance.remove(cartridgeInstanceCacheKey) != null &&
- tenantIdToCartridgeInstance.remove(cartridgeInstanceCacheKey.getTenantId()) != null) {
-
- log.info("Removed tenant " + cartridgeInstanceCacheKey.getTenantId() + "'s cartridge subscription with alias " +
- cartridgeInstanceCacheKey.getCartridgeInstanceAlias() + " from the cache");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCacheKey.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCacheKey.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCacheKey.java
deleted file mode 100644
index ee06bb4..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/cache/CartridgeInstanceCacheKey.java
+++ /dev/null
@@ -1,59 +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.manager.subscription.cache;
-
-public class CartridgeInstanceCacheKey {
-
- private int tenantId;
- private String cartridgeAlias;
-
- public CartridgeInstanceCacheKey (int tenantId, String cartridgeAlias) {
-
- this.tenantId = tenantId;
- this.cartridgeAlias = cartridgeAlias;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public String getCartridgeInstanceAlias() {
- return cartridgeAlias;
- }
-
- public boolean equals (Object object) {
-
- if(object == this) {
- return true;
- }
- else if (object == null || !(object instanceof CartridgeInstanceCacheKey)) {
- return false;
- }
-
- CartridgeInstanceCacheKey subscriptionKey = (CartridgeInstanceCacheKey)object;
- return this.getCartridgeInstanceAlias().equals(subscriptionKey.getCartridgeInstanceAlias()) &&
- this.getTenantId() == subscriptionKey.getTenantId();
- }
-
- public int hashCode () {
-
- return getCartridgeInstanceAlias().hashCode() + Integer.toString(getTenantId()).hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/factory/CartridgeSubscriptionFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/factory/CartridgeSubscriptionFactory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/factory/CartridgeSubscriptionFactory.java
deleted file mode 100644
index 029e090..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/factory/CartridgeSubscriptionFactory.java
+++ /dev/null
@@ -1,91 +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.manager.subscription.factory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.lb.category.LBDataContext;
-import org.apache.stratos.manager.lb.category.LoadBalancerCategory;
-import org.apache.stratos.manager.subscription.*;
-import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-public class CartridgeSubscriptionFactory {
-
- private static Log log = LogFactory.getLog(CartridgeSubscriptionFactory.class);
-
- /**
- * Returns the relevant CartridgeSubscription object for the given criteria
- *
- * @param cartridgeInfo CartridgeInfo instance
- * @param subscriptionTenancyBehaviour SubscriptionTenancyBehaviour instance
- * @return CartridgeSubscription subscription
- * @throws ADCException if no matching criteria is there to create a CartridgeSubscription object
- */
-
- public static CartridgeSubscription getCartridgeSubscriptionInstance(CartridgeInfo cartridgeInfo,
- SubscriptionTenancyBehaviour subscriptionTenancyBehaviour)
- throws ADCException {
-
- //TODO: fix the logic properly
- CartridgeSubscription cartridgeSubscription = null;
- if(cartridgeInfo.getMultiTenant()) {
- if (cartridgeInfo.getProvider().equals(CartridgeConstants.INTERNAL_REPO_BASED_CARTRIDGE_PROVIDER)) {
- cartridgeSubscription = new InternalRepoBasedCartridgeSubscription(cartridgeInfo, subscriptionTenancyBehaviour);
- } else if (cartridgeInfo.getProvider().equals("application")) {
- cartridgeSubscription = new ApplicationCartridgeSubscription(cartridgeInfo, subscriptionTenancyBehaviour);
- } else {
- cartridgeSubscription = new FrameworkCartridgeSubscription(cartridgeInfo, subscriptionTenancyBehaviour);
- }
- } else {
- // TODO: fix properly with cartridgeCategory element
- if(cartridgeInfo.getProvider().equals(CartridgeConstants.DATA_CARTRIDGE_PROVIDER)) {
- cartridgeSubscription = new DataCartridgeSubscription(cartridgeInfo, subscriptionTenancyBehaviour);
- }
- else if (cartridgeInfo.getProvider().equals("application")) {
- cartridgeSubscription = new ApplicationCartridgeSubscription(cartridgeInfo, subscriptionTenancyBehaviour);
- }
- else if (cartridgeInfo.getProvider().equals(CartridgeConstants.INTERNAL_REPO_BASED_CARTRIDGE_PROVIDER)) {
- cartridgeSubscription = new InternalRepoBasedCartridgeSubscription(cartridgeInfo, subscriptionTenancyBehaviour);
- }
- else {
- cartridgeSubscription = new FrameworkCartridgeSubscription(cartridgeInfo, subscriptionTenancyBehaviour);
- }
- }
-
- if(cartridgeSubscription == null) {
- throw new ADCException("Unable to create a CartridgeSubscription subscription for " + cartridgeInfo);
- }
-
- return cartridgeSubscription;
- }
-
- public static CartridgeSubscription getLBCartridgeSubscriptionInstance (LBDataContext lbDataContext, LoadBalancerCategory loadBalancerCategory)
- throws ADCException {
-
- if (!lbDataContext.getLbCartridgeInfo().getProvider().equals("loadbalancer") && !lbDataContext.getLbCartridgeInfo().getProvider().equals("lb")) {
- throw new ADCException("LB cartridge provider should be either lb or loadbalancer");
- }
-
- return new LBCartridgeSubscription(lbDataContext.getLbCartridgeInfo(), null, loadBalancerCategory);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/LBCreationSubscriptionFilter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/LBCreationSubscriptionFilter.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/LBCreationSubscriptionFilter.java
deleted file mode 100644
index c2534a1..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/LBCreationSubscriptionFilter.java
+++ /dev/null
@@ -1,221 +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.manager.subscription.filter;
-
-import java.util.List;
-import java.util.Random;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.LoadbalancerConfig;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.common.Property;
-import org.apache.stratos.common.constants.StratosConstants;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.DuplicateCartridgeAliasException;
-import org.apache.stratos.manager.exception.InvalidCartridgeAliasException;
-import org.apache.stratos.manager.exception.InvalidRepositoryException;
-import org.apache.stratos.manager.exception.PolicyException;
-import org.apache.stratos.manager.exception.RepositoryCredentialsRequiredException;
-import org.apache.stratos.manager.exception.RepositoryRequiredException;
-import org.apache.stratos.manager.exception.RepositoryTransportException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.lb.category.DefaultLoadBalancerCategory;
-import org.apache.stratos.manager.lb.category.ExistingLoadBalancerCategory;
-import org.apache.stratos.manager.lb.category.LBDataContext;
-import org.apache.stratos.manager.lb.category.LoadBalancerCategory;
-import org.apache.stratos.manager.lb.category.ServiceLevelLoadBalancerCategory;
-import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
-import org.apache.stratos.manager.publisher.CartridgeSubscriptionDataPublisher;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.SubscriptionData;
-import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory;
-import org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-/**
- * Responsible for making a subscription for a Load Balancer Cluster,
- * when required.
- */
-public class LBCreationSubscriptionFilter implements SubscriptionFilter {
-
- private static Log log = LogFactory.getLog(LBCreationSubscriptionFilter.class);
-
- @Override
- public Properties execute(CartridgeInfo cartridgeInfo, SubscriptionData subscriptionData) throws ADCException {
-
- LBDataContext lbDataCtxt = null;
- CartridgeSubscription lbCartridgeSubscription = null;
- Properties lbCartridgeSubscriptionProperties = new Properties();
- Properties filterProperties = new Properties();
-
- try {
- // get lb config reference
- LoadbalancerConfig lbConfig = cartridgeInfo.getLbConfig();
- if (lbConfig == null || lbConfig.getProperties() == null) {
- // no LB ref
- if (log.isDebugEnabled()) {
- log.debug("This Service does not require a load balancer. "
- + "[Service Name] "
- + subscriptionData.getCartridgeType());
- }
-
- } else {
-
- // LB ref found, get relevant LB Context data
- lbDataCtxt = CartridgeSubscriptionUtils
- .getLoadBalancerDataContext(
- subscriptionData.getTenantId(),
- subscriptionData.getCartridgeType(),
- subscriptionData.getDeploymentPolicyName(),
- lbConfig);
-
- // subscribe to LB
-// lbCartridgeSubscription = subscribeToLB(subscriptionData,
-// lbDataCtxt, cartridgeInfo);
-
- if (lbDataCtxt.getLbProperperties() != null && !lbDataCtxt.getLbProperperties().isEmpty()) {
- List<Property> lbProperperties = lbDataCtxt.getLbProperperties();
- lbCartridgeSubscriptionProperties.setProperties(lbProperperties.toArray(new Property[lbProperperties.size()]));
- for (Property property : lbProperperties){
- if (StratosConstants.LOAD_BALANCER_REF.equals(property.getName())) {
- filterProperties.addProperty(property);
- }
- }
- }
-
-// if (lbCartridgeSubscription != null) {
-// // determine the LB cluster id, if available
-// Property lbClusterIdProp = new Property();
-// lbClusterIdProp.setName(CartridgeConstants.LB_CLUSTER_ID);
-// lbClusterIdProp.setValue(lbCartridgeSubscription
-// .getClusterDomain());
-// lbCartridgeSubscriptionProperties
-// .addProperty(lbClusterIdProp);
-// filterProperties.addProperty(lbClusterIdProp);
-//
-// // register LB cartridge subscription
-// if (log.isDebugEnabled()) {
-// log.debug(" Registering LB Cartridge subscription ");
-// }
-// CartridgeSubscriptionManager.registerCartridgeSubscription(
-// lbCartridgeSubscription,
-// lbCartridgeSubscriptionProperties,
-// subscriptionData.getPersistence());
-// }
- }
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- throw new ADCException(e.getMessage(), e);
- }
-
- return filterProperties;
- }
-
-// private CartridgeSubscription subscribeToLB (SubscriptionData subscriptionData, LBDataContext lbDataContext,
-// CartridgeInfo serviceCartridgeInfo)
-//
-// throws ADCException, InvalidCartridgeAliasException,
-// DuplicateCartridgeAliasException, PolicyException, UnregisteredCartridgeException, RepositoryRequiredException, RepositoryCredentialsRequiredException,
-// RepositoryTransportException, AlreadySubscribedException, InvalidRepositoryException {
-//
-//
-// if (lbDataContext.getLbCategory() == null || lbDataContext.getLbCategory().equals(StratosConstants.NO_LOAD_BALANCER)) {
-// // no load balancer subscription required generate SubscriptionKey
-// log.info("No LB subscription required for the Subscription with alias: " + subscriptionData.getCartridgeAlias() + ", type: " +
-// subscriptionData.getCartridgeType());
-// return null;
-// }
-//
-// LoadBalancerCategory loadBalancerCategory = null;
-//
-// String lbAlias = "lb" + lbDataContext.getLbCartridgeInfo().getType() + new Random().nextInt();
-//
-// if (lbDataContext.getLbCategory().equals(StratosConstants.EXISTING_LOAD_BALANCERS)) {
-// loadBalancerCategory = new ExistingLoadBalancerCategory();
-//
-// } else if (lbDataContext.getLbCategory().equals(StratosConstants.DEFAULT_LOAD_BALANCER)) {
-// loadBalancerCategory = new DefaultLoadBalancerCategory();
-//
-// } else if (lbDataContext.getLbCategory().equals(StratosConstants.SERVICE_AWARE_LOAD_BALANCER)) {
-// loadBalancerCategory = new ServiceLevelLoadBalancerCategory();
-// }
-//
-// if (loadBalancerCategory == null) {
-// throw new ADCException("The given Load Balancer category " + lbDataContext.getLbCategory() + " not found");
-// }
-//
-// if(lbDataContext.getLbCartridgeInfo().getMultiTenant()) {
-// throw new ADCException("LB Cartridge must be single tenant");
-// }
-// // Set the load balanced service type
-// loadBalancerCategory.setLoadBalancedServiceType(subscriptionData.getCartridgeType());
-//
-// // Set if the load balanced service is multi tenant or not
-// loadBalancerCategory.setLoadBalancedServiceMultiTenant(serviceCartridgeInfo.getMultiTenant());
-//
-// // set the relevant deployment policy
-// loadBalancerCategory.setDeploymentPolicyName(lbDataContext.getDeploymentPolicy());
-//
-// // Create the CartridgeSubscription instance
-// CartridgeSubscription cartridgeSubscription = CartridgeSubscriptionFactory.getLBCartridgeSubscriptionInstance(lbDataContext, loadBalancerCategory);
-//
-// // Generate and set the key
-// String subscriptionKey = CartridgeSubscriptionUtils.generateSubscriptionKey();
-// cartridgeSubscription.setSubscriptionKey(subscriptionKey);
-//
-// // Create repository
-// Repository repository = cartridgeSubscription.manageRepository(null, "", "", false);
-//
-// // Create subscriber
-// Subscriber subscriber = new Subscriber(subscriptionData.getTenantAdminUsername(), subscriptionData.getTenantId(), subscriptionData.getTenantDomain());
-//
-// // create subscription
-// cartridgeSubscription.createSubscription(subscriber, lbAlias, lbDataContext.getAutoscalePolicy(),
-// lbDataContext.getDeploymentPolicy(), repository);
-//
-// // add LB category to the payload
-// if (cartridgeSubscription.getPayloadData() != null) {
-// cartridgeSubscription.getPayloadData().add(CartridgeConstants.LB_CATEGORY, lbDataContext.getLbCategory());
-// }
-//
-// // publishing to bam
-// CartridgeSubscriptionDataPublisher.publish(subscriptionData.getTenantId(),
-// subscriptionData.getTenantAdminUsername(), lbAlias,
-// lbDataContext.getLbCartridgeInfo().getType(),
-// subscriptionData.getRepositoryURL(),
-// serviceCartridgeInfo.getMultiTenant(),
-// lbDataContext.getDeploymentPolicy(),
-// lbDataContext.getAutoscalePolicy(),
-// cartridgeSubscription.getCluster().getClusterDomain(),
-// cartridgeSubscription.getHostName(),
-// cartridgeSubscription.getMappedDomain(), "Subscribed");
-//
-// log.info("Tenant [" + subscriptionData.getTenantId() + "] with username [" + subscriptionData.getTenantAdminUsername() +
-// " subscribed to " + "] Cartridge with Alias " + lbAlias + ", Cartridge Type: " + lbDataContext.getLbCartridgeInfo().getType() +
-// ", Autoscale Policy: " + lbDataContext.getAutoscalePolicy() + ", Deployment Policy: " + lbDataContext.getDeploymentPolicy());
-//
-// return cartridgeSubscription;
-// }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/SubscriptionFilter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/SubscriptionFilter.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/SubscriptionFilter.java
deleted file mode 100644
index 99bb511..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/filter/SubscriptionFilter.java
+++ /dev/null
@@ -1,40 +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.manager.subscription.filter;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.subscription.SubscriptionData;
-
-/**
- * Intercepts the flow of Cartridge Subscription.
- * Implementations of this class would get executed before making the real subscription.
- */
-public interface SubscriptionFilter {
-
- /**
- * Do some pre-processing on a subscription request.
- * @param cartridgeInfo {@link CartridgeInfo}
- * @param subscriptionData {@link SubscriptionData}
- * @return {@link Properties}, if there are any.
- * @throws ADCException on a failure while processing.
- */
- public Properties execute(CartridgeInfo cartridgeInfo, SubscriptionData subscriptionData) throws ADCException ;
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java
deleted file mode 100644
index 8146209..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionMultiTenantBehaviour.java
+++ /dev/null
@@ -1,135 +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.manager.subscription.tenancy;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.publisher.InstanceNotificationPublisher;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-import java.util.Map;
-
-
-public class SubscriptionMultiTenantBehaviour extends SubscriptionTenancyBehaviour {
-
- private static Log log = LogFactory.getLog(SubscriptionMultiTenantBehaviour.class);
-
-
- public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries) throws ADCException, AlreadySubscribedException {
-
- boolean allowMultipleSubscription = Boolean.
- valueOf(System.getProperty(CartridgeConstants.FEATURE_MULTI_TENANT_MULTIPLE_SUBSCRIPTION_ENABLED));
-
- if (!allowMultipleSubscription) {
- // If the cartridge is multi-tenant. We should not let users createSubscription twice.
- boolean subscribed;
-
- try {
- subscribed = hasAlreadySubscribed(subscriber.getTenantId(), cartridgeInfo.getType());
-
- } catch (Exception e) {
- String msg = "Error checking whether the cartridge type " + cartridgeInfo.getType() + " is already subscribed";
- log.error(msg, e);
- throw new ADCException(msg, e);
- }
-
- if (subscribed) {
- String msg = "Already subscribed to " + cartridgeInfo.getType() + ". This multi-tenant cartridge will not be available to createSubscription";
- if (log.isDebugEnabled()) {
- log.debug(msg);
- }
- throw new AlreadySubscribedException(msg, cartridgeInfo.getType());
- }
- }
-
- // get the cluster domain and host name from deployed Service
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
-
- Service deployedService;
- try {
- deployedService = dataInsertionAndRetrievalManager.getService(cartridgeInfo.getType());
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in checking if Service is available is PersistenceManager";
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
-
- if (deployedService == null) {
- String errorMsg = "There is no deployed Service for type " + cartridgeInfo.getType();
- log.error(errorMsg);
- throw new ADCException(errorMsg);
- }
-
- //set the cluster and hostname
- cluster.setClusterDomain(deployedService.getClusterId());
- cluster.setHostName(deployedService.getHostName());
-
- if (repository != null) {
-
- // publish the ArtifactUpdated event
- //log.info(" Multitenant --> Publishing Artifact update event -- ");
- //log.info(" Values : cluster id - " + cluster.getClusterDomain() + " tenant - " + subscriber.getTenantId());
- //InstanceNotificationPublisher publisher = new InstanceNotificationPublisher();
- //publisher.publishArtifactUpdatedEvent(repository, cluster.getClusterDomain(), String.valueOf(subscriber.getTenantId()));
-
- } else {
- if(log.isDebugEnabled()) {
- log.debug("No repository found for subscription with alias: " + alias + ", type: " + cartridgeInfo.getType() +
- ". Not sending the Artifact Updated event");
- }
- }
-
- // no payload
- return null;
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName,
- String deploymentPolicyName, Properties properties, Persistence persistence)
- throws ADCException, UnregisteredCartridgeException {
-
- //nothing to do
- }
-
- public void remove (String clusterId, String alias) throws ADCException, NotSubscribedException {
-
- log.info("Cartridge Subscription with alias " + alias + ", and cluster id " + clusterId +
- " is a multi-tenant cartridge and therefore will not terminate all instances and " +
- "unregister services");
- }
-
- private static boolean hasAlreadySubscribed(int tenantId, String cartridgeType) {
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
- return ( dataInsertionAndRetrievalManager.getCartridgeSubscriptions(tenantId, cartridgeType) == null ||
- dataInsertionAndRetrievalManager.getCartridgeSubscriptions(tenantId, cartridgeType).isEmpty() ) ? false : true;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java
deleted file mode 100644
index e87b7d8..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionSingleTenantBehaviour.java
+++ /dev/null
@@ -1,117 +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.manager.subscription.tenancy;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-public class SubscriptionSingleTenantBehaviour extends SubscriptionTenancyBehaviour {
-
- private static Log log = LogFactory.getLog(SubscriptionSingleTenantBehaviour.class);
-
- /*public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries) throws ADCException, AlreadySubscribedException {
-
- //set the cluster and hostname
- //cartridgeSubscription.getCluster().setClusterDomain(cartridgeSubscription.getAlias() + "." +
- // cartridgeSubscription.getCluster().getHostName() + "." + cartridgeSubscription.getType() + ".domain");
- String clusterId = alias + "." + cartridgeInfo.getType() + ".domain";
-
- // limit the cartridge alias to 30 characters in length
- if (clusterId.length() > 30) {
- clusterId = CartridgeSubscriptionUtils.limitLengthOfString(clusterId, 30);
- }
- cluster.setClusterDomain(clusterId);
- // set hostname
- cluster.setHostName(alias + "." + cluster.getHostName());
-
- //Create the payload
- BasicPayloadData basicPayloadData = CartridgeSubscriptionUtils.createBasicPayload(cartridgeInfo, subscriptionKey, cluster, repository,
- alias, subscriber);
- //Populate the basic payload details
- basicPayloadData.populatePayload();
-
- PayloadData payloadData = PayloadFactory.getPayloadDataInstance(cartridgeInfo.getProvider(),
- cartridgeInfo.getType(), basicPayloadData);
-
- // get the payload parameters defined in the cartridge definition file for this cartridge type
- if (cartridgeInfo.getProperties() != null && cartridgeInfo.getProperties().length != 0) {
-
- for (Property property : cartridgeInfo.getProperties()) {
- // check if a property is related to the payload. Currently this is done by checking if the
- // property name starts with 'payload_parameter.' suffix. If so the payload param name will
- // be taken as the substring from the index of '.' to the end of the property name.
- if (property.getName()
- .startsWith(CartridgeConstants.CUSTOM_PAYLOAD_PARAM_NAME_PREFIX)) {
- String payloadParamName = property.getName();
- payloadData.add(payloadParamName.substring(payloadParamName.indexOf(".") + 1), property.getValue());
- }
- }
- }
-
- //check if there are any custom payload entries defined
- if (customPayloadEntries != null) {
- //add them to the payload
- Set<Map.Entry<String,String>> entrySet = customPayloadEntries.entrySet();
- for (Map.Entry<String, String> entry : entrySet) {
- payloadData.add(entry.getKey(), entry.getValue());
- }
- }
-
- return payloadData;
- } */
-
- /*public void register (CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName,
- String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException {
-
- log.info("Payload: " + payloadData.getCompletePayloadData().toString());
-
- ApplicationManagementUtil.registerService(cartridgeInfo.getType(),
- cluster.getClusterDomain(),
- cluster.getClusterSubDomain(),
- payloadData.getCompletePayloadData(),
- payloadData.getBasicPayloadData().getTenantRange(),
- cluster.getHostName(),
- autoscalePolicyName,
- deploymentPolicyName,
- properties);
- }*/
-
- /*public void remove (String clusterId, String alias) throws ADCException, NotSubscribedException {
- //sending instance cleanup notification for the cluster, so that members in the cluster would aware of the termination
- // and perform the house keeping task.
-
- new InstanceCleanupNotificationService().sendInstanceCleanupNotificationForCluster(clusterId);
-
- log.info("Instance Cleanup Notification sent to Cluster: " + clusterId);
-
- try {
- CloudControllerServiceClient.getServiceClient().unregisterService(clusterId);
-
- } catch (Exception e) {
- String errorMsg = "Error in unregistering service cluster with domain " + clusterId;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Unregistered service cluster, domain " + clusterId);
- }*/
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java
deleted file mode 100644
index 1e16d33..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/tenancy/SubscriptionTenancyBehaviour.java
+++ /dev/null
@@ -1,26 +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.manager.subscription.tenancy;
-
-import org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour;
-
-public abstract class SubscriptionTenancyBehaviour extends CartridgeMgtBehaviour {
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java
deleted file mode 100644
index 9fc90bb..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/utils/CartridgeSubscriptionUtils.java
+++ /dev/null
@@ -1,502 +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.manager.subscription.utils;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.LoadbalancerConfig;
-import org.apache.stratos.cloud.controller.stub.domain.PortMapping;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.common.Property;
-//import org.apache.stratos.cloud.controller.stub.pojo.*;
-import org.apache.stratos.common.constants.StratosConstants;
-import org.apache.stratos.manager.client.AutoscalerServiceClient;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.DuplicateCartridgeAliasException;
-import org.apache.stratos.manager.exception.InvalidCartridgeAliasException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.lb.category.LBDataContext;
-import org.apache.stratos.manager.payload.BasicPayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.messaging.broker.publish.EventPublisher;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.event.tenant.TenantSubscribedEvent;
-import org.apache.stratos.messaging.event.tenant.TenantUnSubscribedEvent;
-import org.apache.stratos.messaging.util.Util;
-
-import java.util.Set;
-import java.util.concurrent.Executor;
-import java.util.regex.Pattern;
-
-public class CartridgeSubscriptionUtils {
-
- private static Log log = LogFactory.getLog(CartridgeSubscriptionUtils.class);
-
- public static BasicPayloadData createBasicPayload(CartridgeInfo cartridgeInfo, String subscriptionKey, Cluster cluster,
- Repository repository, String alias, Subscriber subscriber) {
-
- BasicPayloadData basicPayloadData = new BasicPayloadData();
- basicPayloadData.setApplicationPath(cartridgeInfo.getBaseDir());
- basicPayloadData.setSubscriptionKey(subscriptionKey);
- //basicPayloadData.setDeployment("default");//currently hard coded to default
- basicPayloadData.setMultitenant(String.valueOf(cartridgeInfo.getMultiTenant()));
- basicPayloadData.setPortMappings(createPortMappingPayloadString(cartridgeInfo));
- basicPayloadData.setServiceName(cartridgeInfo.getType());
- basicPayloadData.setProvider(cartridgeInfo.getProvider());
-
- if (repository != null) {
- basicPayloadData.setGitRepositoryUrl(repository.getUrl());
- }
-
- if (cluster != null) {
- basicPayloadData.setClusterId(cluster.getClusterDomain());
- basicPayloadData.setHostName(cluster.getHostName());
- }
-
- if (alias != null) {
- basicPayloadData.setSubscriptionAlias(alias);
- }
-
- if (subscriber != null) {
- basicPayloadData.setTenantId(subscriber.getTenantId());
- }
-
- //TODO:remove. we do not want to know about the tenant rance in subscription!
- if (cartridgeInfo.getMultiTenant()) { //TODO: fix properly
- basicPayloadData.setTenantRange("*");
- } else if (subscriber != null) {
- basicPayloadData.setTenantRange(String.valueOf(subscriber.getTenantId()));
- }
-
- return basicPayloadData;
- }
-
- public static BasicPayloadData createBasicPayload(Service service) {
-
- BasicPayloadData basicPayloadData = new BasicPayloadData();
- basicPayloadData.setApplicationPath(service.getCartridgeInfo().getBaseDir());
- basicPayloadData.setSubscriptionKey(service.getSubscriptionKey());
- basicPayloadData.setClusterId(service.getClusterId());
- //basicPayloadData.setDeployment("default");//currently hard coded to default
- basicPayloadData.setHostName(service.getHostName());
- basicPayloadData.setMultitenant(String.valueOf(service.getCartridgeInfo().getMultiTenant()));
- basicPayloadData.setPortMappings(createPortMappingPayloadString(service.getCartridgeInfo()));
- basicPayloadData.setServiceName(service.getType());
- basicPayloadData.setTenantId(service.getTenantId());
- basicPayloadData.setTenantRange(service.getTenantRange());
-
- return basicPayloadData;
- }
-
-// public static BasicPayloadData createBasicPayload (LBCategoryContext lbCategoryContext) {
-//
-// BasicPayloadData basicPayloadData = new BasicPayloadData();
-// basicPayloadData.setApplicationPath(lbCategoryContext.getCartridgeInfo().getBaseDir());
-// basicPayloadData.setSubscriptionKey(lbCategoryContext.getKey());
-// basicPayloadData.setClusterId(lbCategoryContext.getCluster().getClusterDomain());
-// basicPayloadData.setDeployment("default");//currently hard coded to default
-// basicPayloadData.setHostName(lbCategoryContext.getCluster().getHostName());
-// basicPayloadData.setMultitenant(String.valueOf(lbCategoryContext.getCartridgeInfo().getMultiTenant()));
-// basicPayloadData.setPortMappings(createPortMappingPayloadString(lbCategoryContext.getCartridgeInfo()));
-// basicPayloadData.setServiceName(lbCategoryContext.getLbType());
-//
-// if (lbCategoryContext.getSubscriptionAlias() != null && !lbCategoryContext.getSubscriptionAlias().isEmpty()) {
-// basicPayloadData.setSubscriptionAlias(lbCategoryContext.getSubscriptionAlias());
-// }
-//
-// if (lbCategoryContext.getSubscriber() != null) {
-// basicPayloadData.setTenantId(lbCategoryContext.getSubscriber().getTenantId());
-// }
-//
-// return basicPayloadData;
-// }
-
- private static String createPortMappingPayloadString(CartridgeInfo cartridgeInfo) {
-
- // port mappings
- StringBuilder portMapBuilder = new StringBuilder();
- PortMapping[] portMappings = cartridgeInfo.getPortMappings();
- for (PortMapping portMapping : portMappings) {
- String port = portMapping.getPort();
- portMapBuilder.append(port).append("|");
- }
-
- // remove last "|" character
- String portMappingString = portMapBuilder.toString().replaceAll("\\|$", "");
-
- return portMappingString;
- }
-
- public static String generateSubscriptionKey() {
- return RandomStringUtils.randomAlphanumeric(16);
- }
-
- static class TenantSubscribedEventPublisher implements Runnable {
-
- private int tenantId;
- private String serviceName;
- private Set<String> clusterIds;
-
- public TenantSubscribedEventPublisher(int tenantId, String service, Set<String> clusterIds) {
- this.tenantId = tenantId;
- this.serviceName = service;
- this.clusterIds = clusterIds;
- }
-
- @Override
- public void run() {
- try {
- if (log.isInfoEnabled()) {
- log.info(String.format("Publishing tenant subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName));
- }
- TenantSubscribedEvent subscribedEvent = new TenantSubscribedEvent(tenantId, serviceName, clusterIds);
- String topic = Util.getMessageTopicName(subscribedEvent);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(subscribedEvent);
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error(String.format("Could not publish tenant subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName), e);
- }
- }
-
- }
-
- }
-
- public static void publishTenantSubscribedEvent(int tenantId, String serviceName, Set<String> clusterIds) {
-
-
- Executor exec = new Executor() {
- @Override
- public void execute(Runnable command) {
- command.run();
- }
- };
-
- exec.execute(new TenantSubscribedEventPublisher(tenantId, serviceName, clusterIds));
- }
-
- public static void publishTenantUnSubscribedEvent(int tenantId, String serviceName, Set<String> clusterIds) {
- try {
- if (log.isInfoEnabled()) {
- log.info(String.format("Publishing tenant un-subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName));
- }
- TenantUnSubscribedEvent event = new TenantUnSubscribedEvent(tenantId, serviceName, clusterIds);
- String topic = Util.getMessageTopicName(event);
- EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
- eventPublisher.publish(event);
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error(String.format("Could not publish tenant un-subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName), e);
- }
- }
- }
-
- public static void validateCartridgeAlias(int tenantId, String cartridgeType, String alias) throws InvalidCartridgeAliasException, DuplicateCartridgeAliasException, ADCException {
-
- String patternString = "([a-z0-9]+([-][a-z0-9])*)+";
- Pattern pattern = Pattern.compile(patternString);
-
- if (!pattern.matcher(alias).matches()) {
- String msg = "The alias " + alias + " can contain only alpha-numeric lowercase characters. Please enter a valid alias.";
- log.error(msg);
- throw new InvalidCartridgeAliasException(msg, tenantId, cartridgeType, alias);
- }
-
- boolean isAliasTaken = false;
- try {
- isAliasTaken = isAliasTaken(tenantId, alias);
- } catch (Exception e) {
- String msg = "Exception : " + e.getMessage();
- log.error(msg, e);
- throw new ADCException("Error when checking alias is already taken", e);
- }
-
- if (isAliasTaken) {
- String msg = "The alias " + alias + " is already taken. Please try again with a different alias.";
- log.error(msg);
- throw new DuplicateCartridgeAliasException(msg, cartridgeType, alias);
- }
- }
-
- public static boolean isAliasTaken(int tenantId, String alias) {
-
- DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager();
- // return (dataInsertionAndRetrievalManager.getCartridgeSubscription(tenantId, alias) == null) ? false : true;
- // fixing STRATOS-427, making the alias globally unique
- return (dataInsertionAndRetrievalManager.getCartridgeSubscriptionForAlias(alias) == null) ? false : true;
- }
-
- public static String limitLengthOfString(String source, int length) {
-
- return source.substring(0, length);
- }
-
- public static LBDataContext getLoadBalancerDataContext(int tenantId, String serviceType, String deploymentPolicyName, LoadbalancerConfig lbConfig) throws UnregisteredCartridgeException, ADCException {
-
-// String lbCartridgeType = lbConfig.getType();
-//
-// LBDataContext lbDataCtxt = new LBDataContext();
-// // set tenant Id
-// lbDataCtxt.setTenantId(tenantId);
-//
-// Properties lbReferenceProperties = lbConfig.getProperties();
-//
-// Property lbRefProperty = new Property();
-// lbRefProperty.setName(StratosConstants.LOAD_BALANCER_REF);
-//
-// for (Property prop : lbReferenceProperties.getProperties()) {
-//
-// String name = prop.getName();
-// String value = prop.getValue();
-//
-// // TODO make following a chain of responsibility pattern
-// if (StratosConstants.NO_LOAD_BALANCER.equals(name)) {
-//
-// if ("true".equals(value)) {
-// lbDataCtxt.setLbCategory(StratosConstants.NO_LOAD_BALANCER);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge does not require a load balancer. " + "[Type] " + serviceType);
-// }
-// lbRefProperty.setValue(name);
-// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty);
-// break;
-// }
-// } else if (StratosConstants.EXISTING_LOAD_BALANCERS.equals(name)) {
-//
-// lbDataCtxt.setLbCategory(StratosConstants.EXISTING_LOAD_BALANCERS);
-//
-// String clusterIdsVal = value;
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge refers to existing load balancers. " + "[Type] " + serviceType + "[Referenced Cluster Ids] " + clusterIdsVal);
-// }
-//
-// String[] clusterIds = clusterIdsVal.split(",");
-//
-//// for (String clusterId : clusterIds) {
-//// try {
-//// AutoscalerServiceClient.getServiceClient().checkLBExistenceAgainstPolicy(clusterId, deploymentPolicyName);
-//// } catch (Exception ex) {
-//// // we don't need to throw the error here.
-//// log.error(ex.getMessage(), ex);
-//// }
-//// }
-//
-// lbRefProperty.setValue(name);
-// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty);
-// break;
-//
-// } else if (StratosConstants.DEFAULT_LOAD_BALANCER.equals(name)) {
-//
-// if ("true".equals(value)) {
-//
-// lbDataCtxt.setLbCategory(StratosConstants.DEFAULT_LOAD_BALANCER);
-//
-// lbRefProperty.setValue(name);
-//
-// CartridgeInfo lbCartridgeInfo;
-//
-// try {
-// lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
-//
-// } catch (Exception e) {
-// String message = "Error getting info for " + lbCartridgeType;
-// log.error(message, e);
-// throw new ADCException(message, e);
-// }
-//
-// if (lbCartridgeInfo == null) {
-// String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " +
-// StratosConstants.DEFAULT_LOAD_BALANCER;
-// log.error(msg);
-// throw new ADCException(msg);
-// }
-//
-// lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge uses default load balancer. " + "[Type] " + serviceType);
-// }
-//
-// try {
-// // get the valid policies for lb cartridge
-// DeploymentPolicy[] lbCartridgeDepPolicies =
-// getAutoscalerServiceClient().getDeploymentPolicies(lbCartridgeType);
-// // traverse deployment policies of lb cartridge
-// for (DeploymentPolicy policy : lbCartridgeDepPolicies) {
-//
-// // check existence of the subscribed policy
-// if (deploymentPolicyName.equals(policy.getId())) {
-//
-// if (!getAutoscalerServiceClient().checkDefaultLBExistenceAgainstPolicy(deploymentPolicyName)) {
-// if (log.isDebugEnabled()) {
-// log.debug(" Default LB doesn't exist for deployment policy [" + deploymentPolicyName + "] ");
-// }
-//
-// Properties lbProperties = new Properties();
-//
-// // if LB cartridge definition has properties as well, combine
-// if (lbCartridgeInfo.getProperties() != null && lbCartridgeInfo.getProperties().length > 0) {
-// if (log.isDebugEnabled()) {
-// log.debug(" Combining LB properties ");
-// }
-// lbProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{lbRefProperty}));
-// } else {
-// lbProperties.setProperties(new Property[]{lbRefProperty});
-// }
-//
-// lbDataCtxt.addLBProperties(lbProperties);
-// }
-// }
-// }
-//
-// } catch (Exception ex) {
-// // we don't need to throw the error here.
-// log.error(ex.getMessage(), ex);
-// }
-//
-// // set deployment and autoscaling policies
-// lbDataCtxt.setDeploymentPolicy(deploymentPolicyName);
-// lbDataCtxt.setAutoscalePolicy(lbCartridgeInfo.getDefaultAutoscalingPolicy());
-//
-// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty);
-// break;
-// }
-//
-// } else if (StratosConstants.SERVICE_AWARE_LOAD_BALANCER.equals(name)) {
-//
-// if ("true".equals(value)) {
-//
-// lbDataCtxt.setLbCategory(StratosConstants.SERVICE_AWARE_LOAD_BALANCER);
-//
-// lbRefProperty.setValue(name);
-//
-// CartridgeInfo lbCartridgeInfo;
-//
-// try {
-// lbCartridgeInfo = CloudControllerServiceClient.getServiceClient().getCartridgeInfo(lbCartridgeType);
-//
-// } catch (Exception e) {
-// String message = "Error getting info for " + lbCartridgeType;
-// log.error(message, e);
-// throw new ADCException(message, e);
-// }
-//
-// if (lbCartridgeInfo == null) {
-// String msg = "Please specify a LB cartridge type for the cartridge: " + serviceType + " as category: " +
-// StratosConstants.SERVICE_AWARE_LOAD_BALANCER;
-// log.error(msg);
-// throw new ADCException(msg);
-// }
-//
-// lbDataCtxt.setLbCartridgeInfo(lbCartridgeInfo);
-//
-// // add a property for the service type
-// Property loadBalancedServiceTypeProperty = new Property();
-// loadBalancedServiceTypeProperty.setName(StratosConstants.LOAD_BALANCED_SERVICE_TYPE);
-// // set the load balanced service type
-// loadBalancedServiceTypeProperty.setValue(serviceType);
-//
-// if (log.isDebugEnabled()) {
-// log.debug("This cartridge uses a service aware load balancer. [Type] " + serviceType);
-// }
-//
-// try {
-//
-// // get the valid policies for lb cartridge
-// DeploymentPolicy[] lbCartridgeDepPolicies = getAutoscalerServiceClient().getDeploymentPolicies(lbCartridgeType);
-// // traverse deployment policies of lb cartridge
-// for (DeploymentPolicy policy : lbCartridgeDepPolicies) {
-// // check existence of the subscribed policy
-// if (deploymentPolicyName.equals(policy.getId())) {
-//
-// if (!getAutoscalerServiceClient().checkServiceLBExistenceAgainstPolicy(serviceType, deploymentPolicyName)) {
-//
-// Properties lbProperties = new Properties();
-//
-// // if LB cartridge definition has properties as well, combine
-// if (lbCartridgeInfo.getProperties() != null && lbCartridgeInfo.getProperties().length > 0) {
-// lbProperties.setProperties(combine(lbCartridgeInfo.getProperties(), new Property[]{lbRefProperty, loadBalancedServiceTypeProperty}));
-//
-// } else {
-// lbProperties.setProperties(new Property[]{lbRefProperty, loadBalancedServiceTypeProperty});
-// }
-//
-// // set a payload property for load balanced service type
-// Property payloadProperty = new Property();
-// payloadProperty.setName("LOAD_BALANCED_SERVICE_TYPE"); //TODO: refactor hardcoded name
-// payloadProperty.setValue(serviceType);
-//
-// lbDataCtxt.addLBProperties(lbProperties);
-// }
-// }
-// }
-//
-// } catch (Exception ex) {
-// // we don't need to throw the error here.
-// log.error(ex.getMessage(), ex);
-// }
-//
-// // set deployment and autoscaling policies
-// lbDataCtxt.setDeploymentPolicy(deploymentPolicyName);
-// lbDataCtxt.setAutoscalePolicy(lbCartridgeInfo.getDefaultAutoscalingPolicy());
-//
-// lbDataCtxt.addLoadBalancedServiceProperty(lbRefProperty);
-// break;
-// }
-// }
-// }
-
-// return lbDataCtxt;
- return null;
- }
-
- private static AutoscalerServiceClient getAutoscalerServiceClient() throws ADCException {
-
- try {
- return AutoscalerServiceClient.getServiceClient();
-
- } catch (AxisFault axisFault) {
- String errorMsg = "Error in getting AutoscalerServiceClient instance";
- log.error(errorMsg, axisFault);
- throw new ADCException(errorMsg, axisFault);
- }
- }
-
- private static Property[] combine(Property[] propertyArray1, Property[] propertyArray2) {
-
- int length = propertyArray1.length + propertyArray2.length;
- Property[] combinedProperties = new Property[length];
- System.arraycopy(propertyArray1, 0, combinedProperties, 0, propertyArray1.length);
- System.arraycopy(propertyArray2, 0, combinedProperties, propertyArray1.length, propertyArray2.length);
-
- return combinedProperties;
- }
-}
[13/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
Refining stratos manager component and removing unused code
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/79c69e77
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/79c69e77
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/79c69e77
Branch: refs/heads/master
Commit: 79c69e7750fcdcc6b6af1a6cc2606ec446ac8902
Parents: 8013b2f
Author: Imesh Gunaratne <im...@apache.org>
Authored: Sun Jan 4 10:21:51 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sun Jan 4 10:21:51 2015 +0530
----------------------------------------------------------------------
.../apache/stratos/cli/CommandLineService.java | 589 +++++-----
.../stratos/cli/RestCommandLineService.java | 2 +-
.../stratos/cli/commands/InfoCommand.java | 24 +-
components/org.apache.stratos.manager/pom.xml | 16 +-
.../coordinator/RepositoryNotifier.java | 75 ++
.../behaviour/CartridgeMgtBehaviour.java | 176 ---
.../manager/client/AutoscalerServiceClient.java | 4 +-
.../client/CloudControllerServiceClient.java | 4 +-
.../beans/ApplicationDefinition.java | 95 --
.../application/beans/CartridgeDefinition.java | 67 --
.../application/beans/ComponentDefinition.java | 42 -
.../application/beans/GroupDefinition.java | 101 --
.../application/beans/PropertyBean.java | 49 -
.../beans/SubscribableDefinition.java | 51 -
.../application/beans/SubscribableInfo.java | 131 ---
.../CartridgeSubscriptionConnector.java | 45 -
.../CartridgeSubscriptionConnectorFactory.java | 41 -
.../DataCartridgeSubscriptionConnector.java | 88 --
.../manager/dao/CartridgeSubscriptionInfo.java | 200 ----
.../org/apache/stratos/manager/dao/Cluster.java | 97 --
.../stratos/manager/dao/DataCartridge.java | 62 --
.../apache/stratos/manager/dao/PortMapping.java | 59 -
.../manager/dao/RepositoryCredentials.java | 48 -
.../deploy/cartridge/CartridgeDeployer.java | 38 -
.../cartridge/CartridgeDeploymentManager.java | 26 -
.../cartridge/DefaultCartridgeDeployer.java | 50 -
.../cartridge/DockerCartridgeDeployer.java | 39 -
.../stratos/manager/deploy/service/Service.java | 192 ----
.../service/ServiceDeploymentManager.java | 507 ---------
.../service/multitenant/MultiTenantService.java | 33 -
.../multitenant/lb/DefaultLBService.java | 111 --
.../multitenant/lb/ExistingLBService.java | 54 -
.../service/multitenant/lb/LBService.java | 66 --
.../multitenant/lb/MultiTenantLBService.java | 49 -
.../multitenant/lb/ServiceAwareLBService.java | 139 ---
.../manager/domain/ApplicationDefinition.java | 95 ++
.../manager/domain/ApplicationSubscription.java | 68 ++
.../stratos/manager/domain/Cartridge.java | 332 ++++++
.../manager/domain/CartridgeDefinition.java | 67 ++
.../domain/CartridgeSubscriptionInfo.java | 200 ++++
.../manager/domain/CartridgeWrapper.java | 52 +
.../apache/stratos/manager/domain/Cluster.java | 97 ++
.../manager/domain/ComponentDefinition.java | 40 +
.../stratos/manager/domain/DataCartridge.java | 62 ++
.../manager/domain/DependencyDefinitions.java | 64 ++
.../stratos/manager/domain/GroupDefinition.java | 101 ++
.../apache/stratos/manager/domain/Policy.java | 148 +++
.../manager/domain/PolicyDefinition.java | 83 ++
.../stratos/manager/domain/PortMapping.java | 59 +
.../stratos/manager/domain/PropertyBean.java | 49 +
.../manager/domain/RepositoryCredentials.java | 48 +
.../manager/domain/RepositoryInfoBean.java | 85 ++
.../manager/domain/RepositoryInformation.java | 51 +
.../manager/domain/ServiceGroupDefinition.java | 70 ++
.../manager/domain/SubscribableInfo.java | 131 +++
.../manager/domain/SubscriptionInfo.java | 48 +
.../manager/domain/repository/Repository.java | 87 ++
.../apache/stratos/manager/dto/Cartridge.java | 332 ------
.../stratos/manager/dto/CartridgeWrapper.java | 52 -
.../org/apache/stratos/manager/dto/Policy.java | 148 ---
.../stratos/manager/dto/PolicyDefinition.java | 83 --
.../manager/dto/RepositoryInformation.java | 51 -
.../stratos/manager/dto/SubscriptionInfo.java | 48 -
.../definitions/DependencyDefinitions.java | 64 --
.../definitions/ServiceGroupDefinition.java | 70 --
.../definitions/StartupOrderDefinition.java | 47 -
.../deployer/DefaultServiceGroupDeployer.java | 409 -------
.../grouping/deployer/ServiceGroupDeployer.java | 38 -
.../manager/ServiceGroupingManager.java | 60 --
.../internal/ADCManagementServerComponent.java | 200 ----
.../stratos/manager/internal/DataHolder.java | 70 --
.../internal/ServiceReferenceHolder.java | 43 +
.../StratosManagerServiceComponent.java | 199 ++++
.../category/DefaultLoadBalancerCategory.java | 117 --
.../category/ExistingLoadBalancerCategory.java | 54 -
.../manager/lb/category/LBDataContext.java | 108 --
.../lb/category/LoadBalancerCategory.java | 122 ---
.../ServiceLevelLoadBalancerCategory.java | 119 --
...ratosManagerInstanceStatusEventReceiver.java | 132 ---
.../manager/listener/TenantUserRoleCreator.java | 119 --
.../manager/lookup/ClusterIdToSubscription.java | 102 --
.../manager/lookup/LookupDataHolder.java | 210 ----
.../lookup/RepoUrlToCartridgeSubscriptions.java | 116 --
.../manager/lookup/SubscriptionContext.java | 138 ---
.../lookup/TenantIdToSubscriptionContext.java | 70 --
.../manager/CartridgeSubscriptionManager.java | 803 --------------
.../TenantSynchronizerTaskScheduler.java | 76 ++
.../messaging/TenantSynzhronizerTask.java | 122 +++
.../InstanceNotificationPublisher.java | 70 ++
.../publisher/TenantEventPublisher.java | 124 +++
...ratosManagerInstanceStatusEventReceiver.java | 132 +++
.../StratosManagerTopologyEventReceiver.java | 475 ++++++++
.../ApplicationCartridgePayloadData.java | 27 -
.../manager/payload/BasicPayloadData.java | 232 ----
.../payload/DataCartridgePayloadData.java | 27 -
.../payload/FrameworkCartridgePayloadData.java | 27 -
.../LoadBalancerCartridgePayloadData.java | 27 -
.../stratos/manager/payload/PayloadData.java | 69 --
.../stratos/manager/payload/PayloadFactory.java | 60 --
.../manager/persistence/PersistenceManager.java | 83 --
.../RegistryBasedPersistenceManager.java | 970 -----------------
.../persistence/registry/RegistryManager.java | 207 ++++
.../CartridgeSubscriptionDataPublisher.java | 176 ---
.../InstanceNotificationPublisher.java | 86 --
.../manager/publisher/TenantEventPublisher.java | 124 ---
.../TenantSynchronizerTaskScheduler.java | 76 --
.../publisher/TenantSynzhronizerTask.java | 126 ---
.../manager/registry/RegistryManager.java | 207 ----
.../stratos/manager/repository/Repository.java | 87 --
.../repository/RepositoryNotification.java | 80 --
.../DataInsertionAndRetrievalManager.java | 411 -------
.../InstanceCleanupNotificationService.java | 42 -
.../manager/service/RepositoryInfoBean.java | 85 --
.../CartridgeSubscriptionDataPublisher.java | 176 +++
.../stratos/manager/subscriber/Subscriber.java | 68 --
.../ApplicationCartridgeSubscription.java | 49 -
.../subscription/ApplicationSubscription.java | 78 --
.../subscription/CartridgeSubscription.java | 430 --------
.../subscription/DataCartridgeSubscription.java | 116 --
.../FrameworkCartridgeSubscription.java | 62 --
.../manager/subscription/GroupSubscription.java | 73 --
.../InternalRepoBasedCartridgeSubscription.java | 90 --
.../subscription/LBCartridgeSubscription.java | 112 --
.../subscription/PersistenceContext.java | 78 --
.../manager/subscription/SubscriptionData.java | 217 ----
.../subscription/SubscriptionDomain.java | 48 -
.../cache/CartridgeInstanceCache.java | 119 --
.../cache/CartridgeInstanceCacheKey.java | 59 -
.../factory/CartridgeSubscriptionFactory.java | 91 --
.../filter/LBCreationSubscriptionFilter.java | 221 ----
.../subscription/filter/SubscriptionFilter.java | 40 -
.../SubscriptionMultiTenantBehaviour.java | 135 ---
.../SubscriptionSingleTenantBehaviour.java | 117 --
.../tenancy/SubscriptionTenancyBehaviour.java | 26 -
.../utils/CartridgeSubscriptionUtils.java | 502 ---------
.../model/TopologyClusterInformationModel.java | 296 -----
.../StratosManagerTopologyEventReceiver.java | 477 --------
.../user/management/StratosUserManager.java | 201 ++++
.../user/management/TenantUserRoleManager.java | 119 ++
.../exception/UserManagerException.java | 39 +
.../manager/user/mgt/StratosUserManager.java | 201 ----
.../mgt/exception/UserManagerException.java | 39 -
.../utils/ApplicationManagementUtil.java | 25 +-
.../manager/utils/CartridgeConstants.java | 53 +-
.../stratos/manager/utils/Deserializer.java | 52 -
.../stratos/manager/utils/PolicyHolder.java | 292 -----
.../manager/utils/RepoPasswordMgtUtil.java | 121 ---
.../manager/utils/RepositoryCreator.java | 295 -----
.../stratos/manager/utils/Serializer.java | 160 ---
.../utils/SynchronizeRepositoryRequest.java | 138 ---
.../stratos/manager/utils/UserRoleCreator.java | 2 +-
.../src/main/resources/META-INF/services.xml | 19 -
.../manager/test/CartridgeSubscriptionTest.java | 97 --
.../manager/test/LookupDataHolderTest.java | 282 -----
.../stratos/manager/test/PayloadTest.java | 196 ----
.../stratos/manager/test/PolicyHolderTest.java | 84 --
.../src/test/resources/policies-1.xml | 44 -
.../registry/CarbonRegistry.java | 13 +-
.../rest/endpoint/api/StratosApiV40.java | 159 +--
.../rest/endpoint/api/StratosApiV40Utils.java | 1018 ++++++++----------
.../rest/endpoint/api/StratosApiV41.java | 81 +-
.../rest/endpoint/api/StratosApiV41Utils.java | 649 +++++------
.../stratos/rest/endpoint/mock/MockContext.java | 6 +-
.../rest/endpoint/mock/StratosApiV40Mock.java | 4 +-
.../util/converter/ObjectConverter.java | 190 +++-
165 files changed, 5416 insertions(+), 16602 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineService.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineService.java
index efc7021..57e39d6 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineService.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineService.java
@@ -41,9 +41,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.stratos.cli.exception.CommandException;
import org.apache.stratos.cli.utils.CliUtils;
import org.apache.stratos.cli.utils.RowMapper;
-import org.apache.stratos.manager.dto.Cartridge;
-import org.apache.stratos.manager.dto.PolicyDefinition;
-import org.apache.stratos.manager.dto.SubscriptionInfo;
+import org.apache.stratos.manager.domain.PolicyDefinition;
+import org.apache.stratos.manager.domain.PolicyDefinition;
import org.apache.stratos.manager.stub.ApplicationManagementServiceADCExceptionException;
import org.apache.stratos.manager.stub.ApplicationManagementServiceAlreadySubscribedExceptionException;
import org.apache.stratos.manager.stub.ApplicationManagementServiceDomainMappingExistsExceptionException;
@@ -164,185 +163,185 @@ public class CommandLineService {
}
}
- public void listSubscribedCartridges(final boolean full) throws CommandException {
- try {
- Cartridge[] cartridges = stub.getSubscribedCartridges();
-
- if (cartridges == null) {
- if (logger.isDebugEnabled()) {
- logger.debug("No subscribed cartridges found");
- }
- System.out.println("There are no subscribed cartridges");
- return;
- }
-
- RowMapper<Cartridge> cartridgeMapper = new RowMapper<Cartridge>() {
-
- public String[] getData(Cartridge cartridge) {
- String[] data = full ? new String[9] : new String[7];
- data[0] = cartridge.getCartridgeType();
- data[1] = cartridge.getDisplayName();
- data[2] = cartridge.getVersion();
- data[3] = cartridge.getMultiTenant() ? "Multi-Tenant" : "Single-Tenant";
- data[4] = cartridge.getCartridgeAlias();
- data[5] = cartridge.getStatus();
- data[6] = cartridge.getMultiTenant() ? "N/A" : String.valueOf(cartridge.getActiveInstances());
- if (full) {
- data[7] = getAccessURLs(cartridge);
- data[8] = cartridge.getRepoURL() != null ? cartridge.getRepoURL() : "";
- }
- return data;
- }
- };
-
- List<String> headers = new ArrayList<String>();
- headers.add("Type");
- headers.add("Name");
- headers.add("Version");
- headers.add("Tenancy Model");
- headers.add("Alias");
- headers.add("Status");
- headers.add("Running Instances");
- if (full) {
- headers.add("Access URL(s)");
- headers.add("Repo URL");
- }
-
- System.out.println("Subscribed Cartridges:");
- CliUtils.printTable(cartridges, cartridgeMapper, headers.toArray(new String[headers.size()]));
-
- System.out.println();
-
- } catch (ApplicationManagementServiceADCExceptionException e) {
- handleException("cannot.list.subscribed.cartridges", e);
- } catch (RemoteException e) {
- handleException(e);
- }
- }
-
- public void listAvailableCartridges() throws CommandException {
- try {
- Cartridge[] multiTenantCatridges = stub.getAvailableCartridges(true);
-
- if (multiTenantCatridges == null) {
- if (logger.isDebugEnabled()) {
- logger.debug("No multi-tenant cartridges available");
- }
- System.out.println("There are no multi-tenant cartridges available");
- }
-
- RowMapper<Cartridge> cartridgeMapper = new RowMapper<Cartridge>() {
-
- public String[] getData(Cartridge cartridge) {
- String[] data = new String[3];
- data[0] = cartridge.getCartridgeType();
- data[1] = cartridge.getDisplayName();
- data[2] = cartridge.getVersion();
- return data;
- }
- };
-
- System.out.println("Available Multi-Tenant Cartridges:");
- CliUtils.printTable(multiTenantCatridges, cartridgeMapper, "Type", "Name", "Version");
- System.out.println();
-
- Cartridge[] singleTenantCatridges = stub.getAvailableCartridges(false);
-
- if (singleTenantCatridges == null) {
- if (logger.isDebugEnabled()) {
- logger.debug("No single-tenant cartridges available");
- }
- System.out.println("There are no single-tenant cartridges available");
- }
-
- System.out.println("Available Single-Tenant Cartridges:");
- CliUtils.printTable(singleTenantCatridges, cartridgeMapper, "Type", "Name", "Version");
- System.out.println();
- } catch (ApplicationManagementServiceADCExceptionException e) {
- handleException("cannot.list.available.cartridges", e);
- } catch (RemoteException e) {
- handleException(e);
- }
- }
+// public void listSubscribedCartridges(final boolean full) throws CommandException {
+// try {
+// Cartridge[] cartridges = stub.getSubscribedCartridges();
+//
+// if (cartridges == null) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("No subscribed cartridges found");
+// }
+// System.out.println("There are no subscribed cartridges");
+// return;
+// }
+//
+// RowMapper<Cartridge> cartridgeMapper = new RowMapper<Cartridge>() {
+//
+// public String[] getData(Cartridge cartridge) {
+// String[] data = full ? new String[9] : new String[7];
+// data[0] = cartridge.getCartridgeType();
+// data[1] = cartridge.getDisplayName();
+// data[2] = cartridge.getVersion();
+// data[3] = cartridge.getMultiTenant() ? "Multi-Tenant" : "Single-Tenant";
+// data[4] = cartridge.getCartridgeAlias();
+// data[5] = cartridge.getStatus();
+// data[6] = cartridge.getMultiTenant() ? "N/A" : String.valueOf(cartridge.getActiveInstances());
+// if (full) {
+// data[7] = getAccessURLs(cartridge);
+// data[8] = cartridge.getRepoURL() != null ? cartridge.getRepoURL() : "";
+// }
+// return data;
+// }
+// };
+//
+// List<String> headers = new ArrayList<String>();
+// headers.add("Type");
+// headers.add("Name");
+// headers.add("Version");
+// headers.add("Tenancy Model");
+// headers.add("Alias");
+// headers.add("Status");
+// headers.add("Running Instances");
+// if (full) {
+// headers.add("Access URL(s)");
+// headers.add("Repo URL");
+// }
+//
+// System.out.println("Subscribed Cartridges:");
+// CliUtils.printTable(cartridges, cartridgeMapper, headers.toArray(new String[headers.size()]));
+//
+// System.out.println();
+//
+// } catch (ApplicationManagementServiceADCExceptionException e) {
+// handleException("cannot.list.subscribed.cartridges", e);
+// } catch (RemoteException e) {
+// handleException(e);
+// }
+// }
+
+// public void listAvailableCartridges() throws CommandException {
+// try {
+// Cartridge[] multiTenantCatridges = stub.getAvailableCartridges(true);
+//
+// if (multiTenantCatridges == null) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("No multi-tenant cartridges available");
+// }
+// System.out.println("There are no multi-tenant cartridges available");
+// }
+//
+// RowMapper<Cartridge> cartridgeMapper = new RowMapper<Cartridge>() {
+//
+// public String[] getData(Cartridge cartridge) {
+// String[] data = new String[3];
+// data[0] = cartridge.getCartridgeType();
+// data[1] = cartridge.getDisplayName();
+// data[2] = cartridge.getVersion();
+// return data;
+// }
+// };
+//
+// System.out.println("Available Multi-Tenant Cartridges:");
+// CliUtils.printTable(multiTenantCatridges, cartridgeMapper, "Type", "Name", "Version");
+// System.out.println();
+//
+// Cartridge[] singleTenantCatridges = stub.getAvailableCartridges(false);
+//
+// if (singleTenantCatridges == null) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("No single-tenant cartridges available");
+// }
+// System.out.println("There are no single-tenant cartridges available");
+// }
+//
+// System.out.println("Available Single-Tenant Cartridges:");
+// CliUtils.printTable(singleTenantCatridges, cartridgeMapper, "Type", "Name", "Version");
+// System.out.println();
+// } catch (ApplicationManagementServiceADCExceptionException e) {
+// handleException("cannot.list.available.cartridges", e);
+// } catch (RemoteException e) {
+// handleException(e);
+// }
+// }
- public void listAvailablePolicies() throws CommandException {
- try {
- PolicyDefinition[] policies = stub.getPolicyDefinitions();
-
- if (policies == null) {
- if (logger.isDebugEnabled()) {
- logger.debug("No policies available");
- }
- System.out.println("There are no policies available");
- }
-
- RowMapper<PolicyDefinition> policyMapper = new RowMapper<PolicyDefinition>() {
-
- public String[] getData(PolicyDefinition policyDefinition) {
- String[] data = new String[3];
- data[0] = policyDefinition.getName();
- data[1] = policyDefinition.getDescription();
- data[2] = policyDefinition.getDefaultPolicy() ? "Yes" : "No";
- return data;
- }
- };
-
- CliUtils.printTable(policies, policyMapper, "Policy Name", "Description", "Default");
- System.out.println();
- } catch (RemoteException e) {
- handleException(e);
- }
- }
-
- public void info(String alias) throws CommandException {
- try {
- Cartridge cartridge = null;
- try {
- cartridge = stub.getCartridgeInfo(alias);
- } catch (ApplicationManagementServiceADCExceptionException e) {
- handleException(e);
- return;
- } catch (ApplicationManagementServiceNotSubscribedExceptionException e) {
- handleException("notsubscribed.error", e, alias);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Cartridge Info: {}", new Gson().toJson(cartridge));
- }
- final String FORMAT = "%-20s: %s%n";
- System.out.println();
- System.out.println("Cartridge Information");
- System.out.println("---------------------");
- System.out.format(FORMAT, "Cartridge", cartridge.getCartridgeType());
- System.out.format(FORMAT, "Name", cartridge.getDisplayName());
- System.out.format(FORMAT, "Description", cartridge.getDescription());
- System.out.format(FORMAT, "Version", cartridge.getVersion());
- System.out.format(FORMAT, "Tenancy Model", cartridge.getMultiTenant() ? "Multi-Tenant" : "Single-Tenant");
- System.out.format(FORMAT, "Alias", cartridge.getCartridgeAlias());
- if (StringUtils.isNotBlank(cartridge.getPolicyDescription())) {
- System.out.format(FORMAT, "Policy", cartridge.getPolicyDescription());
- }
- System.out.format(FORMAT, "Access URL(s)", getAccessURLs(cartridge));
- if (StringUtils.isNotBlank(cartridge.getIp())) {
- System.out.format(FORMAT, "Host", cartridge.getIp());
- }
- if (StringUtils.isNotBlank(cartridge.getDbUserName())) {
- System.out.format(FORMAT, "Database Username", cartridge.getDbUserName());
- }
- if (StringUtils.isNotBlank(cartridge.getPassword())) {
- System.out.format(FORMAT, "Password", cartridge.getPassword());
- }
- if (StringUtils.isNotBlank(cartridge.getRepoURL())) {
- System.out.format(FORMAT, "Repository URL", cartridge.getRepoURL());
- }
- System.out.format(FORMAT, "Status", cartridge.getStatus());
- System.out.format(FORMAT, "Running Instances",
- cartridge.getMultiTenant() ? "N/A" : String.valueOf(cartridge.getActiveInstances()));
- System.out.println();
-
- } catch (RemoteException e) {
- handleException(e);
- }
- }
+// public void listAvailablePolicies() throws CommandException {
+// try {
+// PolicyDefinition[] policies = stub.getPolicyDefinitions();
+//
+// if (policies == null) {
+// if (logger.isDebugEnabled()) {
+// logger.debug("No policies available");
+// }
+// System.out.println("There are no policies available");
+// }
+//
+// RowMapper<PolicyDefinition> policyMapper = new RowMapper<PolicyDefinition>() {
+//
+// public String[] getData(PolicyDefinition policyDefinition) {
+// String[] data = new String[3];
+// data[0] = policyDefinition.getName();
+// data[1] = policyDefinition.getDescription();
+// data[2] = policyDefinition.getDefaultPolicy() ? "Yes" : "No";
+// return data;
+// }
+// };
+//
+// CliUtils.printTable(policies, policyMapper, "Policy Name", "Description", "Default");
+// System.out.println();
+// } catch (RemoteException e) {
+// handleException(e);
+// }
+// }
+
+// public void info(String alias) throws CommandException {
+// try {
+// Cartridge cartridge = null;
+// try {
+// cartridge = stub.getCartridgeInfo(alias);
+// } catch (ApplicationManagementServiceADCExceptionException e) {
+// handleException(e);
+// return;
+// } catch (ApplicationManagementServiceNotSubscribedExceptionException e) {
+// handleException("notsubscribed.error", e, alias);
+// }
+// if (logger.isDebugEnabled()) {
+// logger.debug("Cartridge Info: {}", new Gson().toJson(cartridge));
+// }
+// final String FORMAT = "%-20s: %s%n";
+// System.out.println();
+// System.out.println("Cartridge Information");
+// System.out.println("---------------------");
+// System.out.format(FORMAT, "Cartridge", cartridge.getCartridgeType());
+// System.out.format(FORMAT, "Name", cartridge.getDisplayName());
+// System.out.format(FORMAT, "Description", cartridge.getDescription());
+// System.out.format(FORMAT, "Version", cartridge.getVersion());
+// System.out.format(FORMAT, "Tenancy Model", cartridge.getMultiTenant() ? "Multi-Tenant" : "Single-Tenant");
+// System.out.format(FORMAT, "Alias", cartridge.getCartridgeAlias());
+// if (StringUtils.isNotBlank(cartridge.getPolicyDescription())) {
+// System.out.format(FORMAT, "Policy", cartridge.getPolicyDescription());
+// }
+// System.out.format(FORMAT, "Access URL(s)", getAccessURLs(cartridge));
+// if (StringUtils.isNotBlank(cartridge.getIp())) {
+// System.out.format(FORMAT, "Host", cartridge.getIp());
+// }
+// if (StringUtils.isNotBlank(cartridge.getDbUserName())) {
+// System.out.format(FORMAT, "Database Username", cartridge.getDbUserName());
+// }
+// if (StringUtils.isNotBlank(cartridge.getPassword())) {
+// System.out.format(FORMAT, "Password", cartridge.getPassword());
+// }
+// if (StringUtils.isNotBlank(cartridge.getRepoURL())) {
+// System.out.format(FORMAT, "Repository URL", cartridge.getRepoURL());
+// }
+// System.out.format(FORMAT, "Status", cartridge.getStatus());
+// System.out.format(FORMAT, "Running Instances",
+// cartridge.getMultiTenant() ? "N/A" : String.valueOf(cartridge.getActiveInstances()));
+// System.out.println();
+//
+// } catch (RemoteException e) {
+// handleException(e);
+// }
+// }
public void unsubscribe(String alias) throws CommandException {
try {
@@ -402,122 +401,122 @@ public class CommandLineService {
boolean privateRepo, String username, String password, String dataCartridgeType, String dataCartridgeAlias)
throws CommandException {
- SubscriptionInfo subcriptionConnectInfo = null;
- if (StringUtils.isNotBlank(dataCartridgeType) && StringUtils.isNotBlank(dataCartridgeAlias)) {
- System.out.format("Subscribing to data cartridge %s with alias %s.%n", dataCartridgeType,
- dataCartridgeAlias);
- try {
- subcriptionConnectInfo = stub.subscribe(dataCartridgeType, dataCartridgeAlias, null, null, false, null,
- null, null, null);
- System.out.format("You have successfully subscribed to %s cartridge with alias %s.%n",
- dataCartridgeType, dataCartridgeAlias);
- System.out.format("%nSubscribing to %s cartridge and connecting with %s data cartridge.%n", alias,
- dataCartridgeAlias);
- } catch (RemoteException e) {
- handleException(e);
- } catch (ApplicationManagementServiceADCExceptionException e) {
- handleException("cannot.subscribe", e);
- } catch (ApplicationManagementServiceRepositoryRequiredExceptionException e) {
- handleException("repository.required", e);
- } catch (ApplicationManagementServiceUnregisteredCartridgeExceptionException e) {
- handleException("cartridge.notregistered", e, dataCartridgeType);
- } catch (ApplicationManagementServiceInvalidCartridgeAliasExceptionException e) {
- handleException("cartridge.invalid.alias", e);
- } catch (ApplicationManagementServiceAlreadySubscribedExceptionException e) {
- handleException("cartridge.already.subscribed", e, e.getFaultMessage().getAlreadySubscribedException()
- .getCartridgeType());
- } catch (ApplicationManagementServiceDuplicateCartridgeAliasExceptionException e) {
- handleException("cartridge.alias.duplicate", e, dataCartridgeAlias);
- } catch (ApplicationManagementServicePolicyExceptionException e) {
- handleException("policy.error", e);
- } catch (ApplicationManagementServiceRepositoryTransportExceptionException e) {
- handleException("repository.transport.error", e, externalRepoURL);
- } catch (ApplicationManagementServiceRepositoryCredentialsRequiredExceptionException e) {
- handleException("repository.credentials.required", e, externalRepoURL);
- } catch (ApplicationManagementServiceInvalidRepositoryExceptionException e) {
- handleException("repository.invalid.error", e, externalRepoURL);
- }
- }
-
-
- try {
- SubscriptionInfo subcriptionInfo = stub.subscribe(cartridgeType, alias, policy, externalRepoURL,
- privateRepo, username, password, dataCartridgeType, dataCartridgeAlias);
-
- System.out.format("You have successfully subscribed to %s cartridge with alias %s.%n", cartridgeType, alias);
-
- String repoURL = null;
- String hostnames = null;
- String hostnamesLabel = null;
- if (subcriptionInfo != null) {
- repoURL = subcriptionInfo.getRepositoryURL();
- hostnames = subcriptionInfo.getHostname();
- hostnamesLabel = "host name";
-
- if (repoURL != null) {
- System.out.println("GIT Repository URL: " + repoURL);
- }
-
- Cartridge cart = stub.getCartridgeInfo(alias);
- System.out.format("Your application is being published here. %s%n", getAccessURLs(cart));
- }
- if (subcriptionConnectInfo != null) {
- hostnames += ", " + subcriptionConnectInfo.getHostname();
- hostnamesLabel = "host names";
-
- Cartridge cart = stub.getCartridgeInfo(alias);
- System.out.format("Your data application is being published here. %s%n", getAccessURLs(cart));
- }
- if (externalRepoURL != null) {
- String takeTimeMsg = "(this might take few minutes... depending on repo size)\n";
- System.out.println(takeTimeMsg);
- }
-
- System.out.format("Please map the %s \"%s\" to ELB IP%n", hostnamesLabel, hostnames);
- } catch (RemoteException e) {
- handleException(e);
- } catch (ApplicationManagementServiceADCExceptionException e) {
- handleException("cannot.subscribe", e);
- } catch (ApplicationManagementServiceRepositoryRequiredExceptionException e) {
- handleException("repository.required", e);
- } catch (ApplicationManagementServiceUnregisteredCartridgeExceptionException e) {
- handleException("cartridge.notregistered", e, cartridgeType);
- } catch (ApplicationManagementServiceInvalidCartridgeAliasExceptionException e) {
- handleException("cartridge.invalid.alias", e);
- } catch (ApplicationManagementServiceAlreadySubscribedExceptionException e) {
- handleException("cartridge.already.subscribed", e, e.getFaultMessage().getAlreadySubscribedException()
- .getCartridgeType());
- } catch (ApplicationManagementServiceDuplicateCartridgeAliasExceptionException e) {
- handleException("cartridge.alias.duplicate", e, alias);
- } catch (ApplicationManagementServicePolicyExceptionException e) {
- handleException("policy.error", e);
- } catch (ApplicationManagementServiceRepositoryTransportExceptionException e) {
- handleException("repository.transport.error", e, externalRepoURL);
- } catch (ApplicationManagementServiceRepositoryCredentialsRequiredExceptionException e) {
- handleException("repository.credentials.required", e, externalRepoURL);
- } catch (ApplicationManagementServiceInvalidRepositoryExceptionException e) {
- handleException("repository.invalid.error", e, externalRepoURL);
- } catch (ApplicationManagementServiceNotSubscribedExceptionException e) {
- handleException("notsubscribed.error", e, alias);
- }
+// SubscriptionInfo subcriptionConnectInfo = null;
+// if (StringUtils.isNotBlank(dataCartridgeType) && StringUtils.isNotBlank(dataCartridgeAlias)) {
+// System.out.format("Subscribing to data cartridge %s with alias %s.%n", dataCartridgeType,
+// dataCartridgeAlias);
+// try {
+// subcriptionConnectInfo = stub.subscribe(dataCartridgeType, dataCartridgeAlias, null, null, false, null,
+// null, null, null);
+// System.out.format("You have successfully subscribed to %s cartridge with alias %s.%n",
+// dataCartridgeType, dataCartridgeAlias);
+// System.out.format("%nSubscribing to %s cartridge and connecting with %s data cartridge.%n", alias,
+// dataCartridgeAlias);
+// } catch (RemoteException e) {
+// handleException(e);
+// } catch (ApplicationManagementServiceADCExceptionException e) {
+// handleException("cannot.subscribe", e);
+// } catch (ApplicationManagementServiceRepositoryRequiredExceptionException e) {
+// handleException("repository.required", e);
+// } catch (ApplicationManagementServiceUnregisteredCartridgeExceptionException e) {
+// handleException("cartridge.notregistered", e, dataCartridgeType);
+// } catch (ApplicationManagementServiceInvalidCartridgeAliasExceptionException e) {
+// handleException("cartridge.invalid.alias", e);
+// } catch (ApplicationManagementServiceAlreadySubscribedExceptionException e) {
+// handleException("cartridge.already.subscribed", e, e.getFaultMessage().getAlreadySubscribedException()
+// .getCartridgeType());
+// } catch (ApplicationManagementServiceDuplicateCartridgeAliasExceptionException e) {
+// handleException("cartridge.alias.duplicate", e, dataCartridgeAlias);
+// } catch (ApplicationManagementServicePolicyExceptionException e) {
+// handleException("policy.error", e);
+// } catch (ApplicationManagementServiceRepositoryTransportExceptionException e) {
+// handleException("repository.transport.error", e, externalRepoURL);
+// } catch (ApplicationManagementServiceRepositoryCredentialsRequiredExceptionException e) {
+// handleException("repository.credentials.required", e, externalRepoURL);
+// } catch (ApplicationManagementServiceInvalidRepositoryExceptionException e) {
+// handleException("repository.invalid.error", e, externalRepoURL);
+// }
+// }
+//
+//
+// try {
+// SubscriptionInfo subcriptionInfo = stub.subscribe(cartridgeType, alias, policy, externalRepoURL,
+// privateRepo, username, password, dataCartridgeType, dataCartridgeAlias);
+//
+// System.out.format("You have successfully subscribed to %s cartridge with alias %s.%n", cartridgeType, alias);
+//
+// String repoURL = null;
+// String hostnames = null;
+// String hostnamesLabel = null;
+// if (subcriptionInfo != null) {
+// repoURL = subcriptionInfo.getRepositoryURL();
+// hostnames = subcriptionInfo.getHostname();
+// hostnamesLabel = "host name";
+//
+// if (repoURL != null) {
+// System.out.println("GIT Repository URL: " + repoURL);
+// }
+//
+// Cartridge cart = stub.getCartridgeInfo(alias);
+// System.out.format("Your application is being published here. %s%n", getAccessURLs(cart));
+// }
+// if (subcriptionConnectInfo != null) {
+// hostnames += ", " + subcriptionConnectInfo.getHostname();
+// hostnamesLabel = "host names";
+//
+// Cartridge cart = stub.getCartridgeInfo(alias);
+// System.out.format("Your data application is being published here. %s%n", getAccessURLs(cart));
+// }
+// if (externalRepoURL != null) {
+// String takeTimeMsg = "(this might take few minutes... depending on repo size)\n";
+// System.out.println(takeTimeMsg);
+// }
+//
+// System.out.format("Please map the %s \"%s\" to ELB IP%n", hostnamesLabel, hostnames);
+// } catch (RemoteException e) {
+// handleException(e);
+// } catch (ApplicationManagementServiceADCExceptionException e) {
+// handleException("cannot.subscribe", e);
+// } catch (ApplicationManagementServiceRepositoryRequiredExceptionException e) {
+// handleException("repository.required", e);
+// } catch (ApplicationManagementServiceUnregisteredCartridgeExceptionException e) {
+// handleException("cartridge.notregistered", e, cartridgeType);
+// } catch (ApplicationManagementServiceInvalidCartridgeAliasExceptionException e) {
+// handleException("cartridge.invalid.alias", e);
+// } catch (ApplicationManagementServiceAlreadySubscribedExceptionException e) {
+// handleException("cartridge.already.subscribed", e, e.getFaultMessage().getAlreadySubscribedException()
+// .getCartridgeType());
+// } catch (ApplicationManagementServiceDuplicateCartridgeAliasExceptionException e) {
+// handleException("cartridge.alias.duplicate", e, alias);
+// } catch (ApplicationManagementServicePolicyExceptionException e) {
+// handleException("policy.error", e);
+// } catch (ApplicationManagementServiceRepositoryTransportExceptionException e) {
+// handleException("repository.transport.error", e, externalRepoURL);
+// } catch (ApplicationManagementServiceRepositoryCredentialsRequiredExceptionException e) {
+// handleException("repository.credentials.required", e, externalRepoURL);
+// } catch (ApplicationManagementServiceInvalidRepositoryExceptionException e) {
+// handleException("repository.invalid.error", e, externalRepoURL);
+// } catch (ApplicationManagementServiceNotSubscribedExceptionException e) {
+// handleException("notsubscribed.error", e, alias);
+// }
}
- private String getAccessURLs(Cartridge cartridge) {
- String[] accessURLs = cartridge.getAccessURLs();
- StringBuilder urlBuilder = new StringBuilder();
- if (accessURLs != null) {
- for (int i = 0; i < accessURLs.length; i++) {
- String url = accessURLs[i];
- if (url != null) {
- if (i > 0) {
- urlBuilder.append(", ");
- }
- urlBuilder.append(url);
- }
- }
- }
- return urlBuilder.toString();
- }
+// private String getAccessURLs(Cartridge cartridge) {
+// String[] accessURLs = cartridge.getAccessURLs();
+// StringBuilder urlBuilder = new StringBuilder();
+// if (accessURLs != null) {
+// for (int i = 0; i < accessURLs.length; i++) {
+// String url = accessURLs[i];
+// if (url != null) {
+// if (i > 0) {
+// urlBuilder.append(", ");
+// }
+// urlBuilder.append(url);
+// }
+// }
+// }
+// return urlBuilder.toString();
+// }
private void handleException(Exception e) throws CommandException {
if (logger.isDebugEnabled()) {
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index 23d6f24..d1fdefd 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -44,7 +44,7 @@ import org.apache.stratos.common.beans.cartridge.definition.IaasProviderBean;
import org.apache.stratos.common.beans.kubernetes.KubernetesCluster;
import org.apache.stratos.common.beans.kubernetes.KubernetesHost;
import org.apache.stratos.common.beans.topology.Cluster;
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
+import org.apache.stratos.manager.domain.ApplicationDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/InfoCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/InfoCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/InfoCommand.java
index a15e215..804d7e0 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/InfoCommand.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/InfoCommand.java
@@ -54,17 +54,19 @@ public class InfoCommand implements Command<StratosCommandContext> {
if (logger.isDebugEnabled()) {
logger.debug("Executing {} command...", getName());
}
- if (args != null && args.length == 1) {
- String alias = args[0];
- if (logger.isDebugEnabled()) {
- logger.debug("Getting info {}", alias);
- }
- CommandLineService.getInstance().info(alias);
- return CliConstants.COMMAND_SUCCESSFULL;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.COMMAND_FAILED;
- }
+ throw new RuntimeException("Not implemented");
+
+// if (args != null && args.length == 1) {
+// String alias = args[0];
+// if (logger.isDebugEnabled()) {
+// logger.debug("Getting info {}", alias);
+// }
+// CommandLineService.getInstance().info(alias);
+// return CliConstants.COMMAND_SUCCESSFULL;
+// } else {
+// context.getStratosApplication().printUsage(getName());
+// return CliConstants.COMMAND_FAILED;
+// }
}
@Override
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/pom.xml b/components/org.apache.stratos.manager/pom.xml
index d95fbd8..8e5cfff 100644
--- a/components/org.apache.stratos.manager/pom.xml
+++ b/components/org.apache.stratos.manager/pom.xml
@@ -29,8 +29,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>org.apache.stratos.manager</artifactId>
<packaging>bundle</packaging>
- <name>Apache Stratos - Manager BE</name>
- <description>BE functionalities of SM</description>
+ <name>Apache Stratos - Manager</name>
+ <description>Stratos Manager (SM)</description>
<url>http://apache.org</url>
<dependencies>
@@ -38,8 +38,6 @@
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.ws.client</artifactId>
</dependency>
- <!--<dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId>
- </dependency> -->
<dependency>
<groupId>org.apache.stratos</groupId>
<artifactId>org.apache.stratos.cloud.controller.service.stub</artifactId>
@@ -50,30 +48,21 @@
<artifactId>org.apache.stratos.autoscaler.service.stub</artifactId>
<version>${project.version}</version>
</dependency>
- <!--dependency>
- <groupId>org.apache.stratos</groupId>
- <artifactId>org.apache.stratos.adc.topology.mgt</artifactId>
- <version>${project.version}</version>
- </dependency-->
-
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<version>${wso2carbon.version}</version>
</dependency>
-
<dependency>
<groupId>org.apache.stratos</groupId>
<artifactId>org.apache.stratos.cartridge.agent.stub</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<artifactId>jdbc-pool</artifactId>
<version>${version.tomcat}.wso2v1</version>
</dependency>
-
<dependency>
<groupId>com.gitblit</groupId>
<artifactId>gitblit</artifactId>
@@ -120,7 +109,6 @@
<version>2.2.2</version>
<scope>provided</scope>
</dependency>
-
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>mqtt-client</artifactId>
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/artifact/distribution/coordinator/RepositoryNotifier.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/artifact/distribution/coordinator/RepositoryNotifier.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/artifact/distribution/coordinator/RepositoryNotifier.java
new file mode 100644
index 0000000..b02f20b
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/artifact/distribution/coordinator/RepositoryNotifier.java
@@ -0,0 +1,75 @@
+/**
+ * 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.manager.artifact.distribution.coordinator;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class RepositoryNotifier {
+
+ private static final Log log = LogFactory.getLog(RepositoryNotifier.class);
+
+ public void updateRepository(String url) {
+
+ if ( StringUtils.isNotBlank(url)) {
+// Set<CartridgeSubscription> cartridgeSubscriptions = new DataInsertionAndRetrievalManager().
+// getCartridgeSubscriptionForRepository(url);
+//
+// if (cartridgeSubscriptions == null || cartridgeSubscriptions.isEmpty()) {
+// // No subscriptions, return
+// if (log.isDebugEnabled()) {
+// log.debug("No subscription information found for repo url : " + url);
+// }
+//
+// return;
+// }
+//
+// for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) {
+// updateRepository(cartridgeSubscription);
+// }
+ }
+ }
+
+// public void updateRepository(CartridgeSubscription cartridgeSubscription) {
+// Repository repository = cartridgeSubscription.getRepository();
+// if (repository != null) {
+// InstanceNotificationPublisher publisher = new InstanceNotificationPublisher();
+//
+// publisher.publishArtifactUpdatedEvent(
+// String.valueOf(cartridgeSubscription.getCluster().getClusterDomain()),
+// String.valueOf(cartridgeSubscription.getSubscriber().getTenantId()),
+// repository.getUrl(),
+// repository.getUserName(),
+// repository.getPassword(),
+// repository.isCommitEnabled());
+//
+// if (log.isInfoEnabled()) {
+// log.info(String.format("Artifact updated event published: %s [cartridge-type] %s " +
+// "%s [subscription-alias] %s [repo-url] %s",
+// cartridgeSubscription.getType(), cartridgeSubscription.getAlias(), repository.getUrl()));
+// }
+// } else {
+// if (log.isWarnEnabled()) {
+// log.warn("No repository found for subscription with alias: " + cartridgeSubscription.getAlias()
+// + ", type: " + cartridgeSubscription.getType() + ". Not sending artifact updated event");
+// }
+// }
+// }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
deleted file mode 100644
index 1419f00..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/behaviour/CartridgeMgtBehaviour.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package org.apache.stratos.manager.behaviour;
-/*
- * 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.
- */
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.NotSubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.BasicPayloadData;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.payload.PayloadFactory;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.service.InstanceCleanupNotificationService;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.subscription.utils.CartridgeSubscriptionUtils;
-import org.apache.stratos.manager.utils.ApplicationManagementUtil;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-
-public abstract class CartridgeMgtBehaviour implements Serializable {
-
- private static final long serialVersionUID = 6529685098267757690L;
-
- private static Log log = LogFactory.getLog(CartridgeMgtBehaviour.class);
-
- public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries) throws ADCException, AlreadySubscribedException {
-
- // set cluster domain
- cluster.setClusterDomain(generateClusterId(alias, cartridgeInfo.getType()));
- // set hostname
- cluster.setHostName(generateHostName(alias, cartridgeInfo.getHostName()));
-
- return createPayload(cartridgeInfo, subscriptionKey, subscriber, cluster, repository, alias, customPayloadEntries);
- }
-
- protected String generateClusterId (String alias, String cartridgeType) {
-
- String clusterId = alias + "." + cartridgeType + ".domain";
- // limit the cartridge alias to 30 characters in length
- if (clusterId.length() > 30) {
- clusterId = CartridgeSubscriptionUtils.limitLengthOfString(clusterId, 30);
- }
-
- return clusterId;
- }
-
- protected String generateHostName (String alias, String cartridgeDefinitionHostName) {
-
- return alias + "." + cartridgeDefinitionHostName;
- }
-
- protected PayloadData createPayload (CartridgeInfo cartridgeInfo, String subscriptionKey, Subscriber subscriber, Cluster cluster,
- Repository repository, String alias, Map<String, String> customPayloadEntries) throws ADCException {
-
- //Create the payload
- BasicPayloadData basicPayloadData = CartridgeSubscriptionUtils.createBasicPayload(cartridgeInfo, subscriptionKey, cluster, repository, alias, subscriber);
- //Populate the basic payload details
- basicPayloadData.populatePayload();
-
- PayloadData payloadData = PayloadFactory.getPayloadDataInstance(cartridgeInfo.getProvider(),
- cartridgeInfo.getType(), basicPayloadData);
-
- boolean isDeploymentParam = false;
- // get the payload parameters defined in the cartridge definition file for this cartridge type
- if (cartridgeInfo.getProperties() != null && cartridgeInfo.getProperties().length != 0) {
-
- org.apache.stratos.common.Properties cartridgeProps = ApplicationManagementUtil
- .toCommonProperties(cartridgeInfo.getProperties());
-
- if (cartridgeProps != null) {
-
- for (org.apache.stratos.common.Property property : cartridgeProps.getProperties()) {
- // check if a property is related to the payload. Currently
- // this is done by checking if the
- // property name starts with 'payload_parameter.' suffix. If
- // so the payload param name will
- // be taken as the substring from the index of '.' to the
- // end of the property name.
- if (property.getName().startsWith(CartridgeConstants.CUSTOM_PAYLOAD_PARAM_NAME_PREFIX)) {
- String payloadParamName = property.getName();
- String payloadParamSubstring = payloadParamName.substring(payloadParamName.indexOf(".") + 1);
- if ("DEPLOYMENT".equals(payloadParamSubstring)) {
- isDeploymentParam = true;
- }
- payloadData.add(payloadParamSubstring, String.valueOf(property.getValue()));
- }
- }
- }
- }
-
- // DEPLOYMENT payload param must be set because its used by puppet agent
- // to generate the hostname. Therefore, if DEPLOYMENT is not set in cartridge properties,
- // adding the DEPLOYMENT="default" param
- if(!isDeploymentParam) {
- payloadData.add("DEPLOYMENT", "default");
- }
- //check if there are any custom payload entries defined
- if (customPayloadEntries != null) {
- //add them to the payload
- Set<Map.Entry<String,String>> entrySet = customPayloadEntries.entrySet();
- for (Map.Entry<String, String> entry : entrySet) {
- payloadData.add(entry.getKey(), entry.getValue());
- }
- }
-
- return payloadData;
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException {
- if(payloadData != null) {
- log.info("Payload: " + payloadData.getCompletePayloadData().toString());
- }else {
- log.info("Payload is null");
- }
-
- ApplicationManagementUtil.registerService(cartridgeInfo.getType(),
- cluster.getClusterDomain(),
- cluster.getClusterSubDomain(),
- payloadData.getCompletePayloadData(),
- payloadData.getBasicPayloadData().getTenantRange(),
- cluster.getHostName(),
- autoscalePolicyName,
- deploymentPolicyName,
- properties,
- persistence);
- }
-
- public void remove(String clusterId, String alias) throws ADCException, NotSubscribedException {
-
- //sending instance cleanup notification for the cluster, so that members in the cluster would aware of the termination
- // and perform the house keeping task.
-
- new InstanceCleanupNotificationService().sendInstanceCleanupNotificationForCluster(clusterId);
-
- log.info("Instance Cleanup Notification sent to Cluster: " + clusterId);
-
- try {
- CloudControllerServiceClient.getServiceClient().unregisterService(clusterId);
-
- } catch (Exception e) {
- String errorMsg = "Error in unregistering service cluster with domain " + clusterId;
- log.error(errorMsg);
- throw new ADCException(errorMsg, e);
- }
-
- log.info("Unregistered service cluster, domain " + clusterId);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
index c14e7c4..2976d08 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/AutoscalerServiceClient.java
@@ -31,7 +31,7 @@ import org.apache.stratos.autoscaler.stub.*;
import org.apache.stratos.autoscaler.stub.autoscale.policy.AutoscalePolicy;
import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.internal.DataHolder;
+import org.apache.stratos.manager.internal.ServiceReferenceHolder;
import org.apache.stratos.manager.utils.ApplicationManagementUtil;
import org.apache.stratos.manager.utils.CartridgeConstants;
@@ -52,7 +52,7 @@ public class AutoscalerServiceClient {
String autosclaerConnectionTimeout =
System.getProperty(CartridgeConstants.AUTOSCALER_CONNECTION_TIMEOUT) == null ? "300000" : System.getProperty(CartridgeConstants.AUTOSCALER_CONNECTION_TIMEOUT);
- ConfigurationContext clientConfigContext = DataHolder.getClientConfigContext();
+ ConfigurationContext clientConfigContext = ServiceReferenceHolder.getClientConfigContext();
try {
stub = new AutoScalerServiceStub(clientConfigContext, epr);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, new Integer(autosclaerSocketTimeout));
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
index 88687f3..dc9bccc 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/client/CloudControllerServiceClient.java
@@ -30,7 +30,7 @@ import org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesClus
import org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesHost;
import org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesMaster;
import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.internal.DataHolder;
+import org.apache.stratos.manager.internal.ServiceReferenceHolder;
import org.apache.stratos.manager.utils.ApplicationManagementUtil;
import org.apache.stratos.manager.utils.CartridgeConstants;
@@ -50,7 +50,7 @@ public class CloudControllerServiceClient {
String ccConnectionTimeout =
System.getProperty(CartridgeConstants.CC_CONNECTION_TIMEOUT) == null ? "300000" : System.getProperty(CartridgeConstants.CC_CONNECTION_TIMEOUT);
- ConfigurationContext clientConfigContext = DataHolder.getClientConfigContext();
+ ConfigurationContext clientConfigContext = ServiceReferenceHolder.getClientConfigContext();
try {
stub = new CloudControllerServiceStub(clientConfigContext, epr);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.SO_TIMEOUT, new Integer(ccSocketTimeout));
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java
deleted file mode 100644
index 4e1fef6..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java
+++ /dev/null
@@ -1,95 +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.manager.composite.application.beans;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class ApplicationDefinition implements Serializable {
-
- private static final long serialVersionUID = -2829206180707597651L;
-
- private String applicationId;
- private String name;
- private String description;
- private String alias;
- private ComponentDefinition components;
- private String status;
- private List<PropertyBean> property;
-
- public String getApplicationId() {
- return applicationId;
- }
-
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public ComponentDefinition getComponents() {
- return components;
- }
-
- public void setComponents(ComponentDefinition components) {
- this.components = components;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- public List<PropertyBean> getProperty() {
- return property;
- }
-
- public void setProperty(List<PropertyBean> property) {
- this.property = property;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java
deleted file mode 100644
index 8339d65..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java
+++ /dev/null
@@ -1,67 +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.manager.composite.application.beans;
-
-import java.io.Serializable;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement
-public class CartridgeDefinition implements Serializable {
-
- private static final long serialVersionUID = 8968224678298479827L;
-
- private String type;
- private int cartridgeMin;
- private int cartridgeMax;
- private SubscribableInfo subscribableInfo;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public int getCartridgeMin() {
- return cartridgeMin;
- }
-
- public void setCartridgeMin(int cartridgeMin) {
- this.cartridgeMin = cartridgeMin;
- }
-
- public int getCartridgeMax() {
- return cartridgeMax;
- }
-
- public void setCartridgeMax(int cartridgeMax) {
- this.cartridgeMax = cartridgeMax;
- }
-
- public SubscribableInfo getSubscribableInfo() {
- return subscribableInfo;
- }
-
- public void setSubscribableInfo(SubscribableInfo subscribableInfo) {
- this.subscribableInfo = subscribableInfo;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ComponentDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ComponentDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ComponentDefinition.java
deleted file mode 100644
index 851ab1d..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ComponentDefinition.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.stratos.manager.composite.application.beans;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
-
-@XmlRootElement(name = "components")
-public class ComponentDefinition implements Serializable {
-
- private static final long serialVersionUID = -5932265453191494386L;
-
- private List<GroupDefinition> groups;
- private DependencyDefinitions dependencies;
- private List<CartridgeDefinition> cartridges;
-
- public List<GroupDefinition> getGroups() {
- return groups;
- }
-
- public void setGroups(List<GroupDefinition> groups) {
- this.groups = groups;
- }
-
- public DependencyDefinitions getDependencies() {
- return dependencies;
- }
-
- public void setDependencies(DependencyDefinitions dependencies) {
- this.dependencies = dependencies;
- }
-
- public List<CartridgeDefinition> getCartridges() {
- return cartridges;
- }
-
- public void setCartridges(List<CartridgeDefinition> cartridges) {
- this.cartridges = cartridges;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java
deleted file mode 100644
index 109370d..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java
+++ /dev/null
@@ -1,101 +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.manager.composite.application.beans;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.List;
-
-@XmlRootElement(name = "groups")
-public class GroupDefinition implements Serializable {
-
- private static final long serialVersionUID = 7261380706841894892L;
-
- private String name;
-
- private String alias;
-
- private int groupMinInstances;
-
- private int groupMaxInstances;
-
- public boolean isGroupScalingEnabled;
-
- private List<CartridgeDefinition> cartridges;
-
- private List<GroupDefinition> groups;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public int getGroupMinInstances() {
- return groupMinInstances;
- }
-
- public void setGroupMinInstances(int groupMinInstances) {
- this.groupMinInstances = groupMinInstances;
- }
-
- public int getGroupMaxInstances() {
- return groupMaxInstances;
- }
-
- public void setGroupMaxInstances(int groupMaxInstances) {
- this.groupMaxInstances = groupMaxInstances;
- }
-
- public boolean isGroupScalingEnabled() {
- return isGroupScalingEnabled;
- }
-
- public void setGroupScalingEnabled(boolean isGroupScalingEnabled) {
- this.isGroupScalingEnabled = isGroupScalingEnabled;
- }
-
- public List<CartridgeDefinition> getCartridges() {
- return cartridges;
- }
-
- public void setCartridges(List<CartridgeDefinition> cartridges) {
- this.cartridges = cartridges;
- }
-
- public List<GroupDefinition> getGroups() {
- return groups;
- }
-
- public void setGroups(List<GroupDefinition> groups) {
- this.groups = groups;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/PropertyBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/PropertyBean.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/PropertyBean.java
deleted file mode 100644
index 08e71bc..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/PropertyBean.java
+++ /dev/null
@@ -1,49 +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.manager.composite.application.beans;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-
-@XmlRootElement(name = "property")
-public class PropertyBean implements Serializable {
-
- private static final long serialVersionUID = 5756598782384376873L;
-
- private String name;
-
- private String value;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java
deleted file mode 100644
index 497980b..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java
+++ /dev/null
@@ -1,51 +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.manager.composite.application.beans;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-
-@XmlRootElement (name = "subscribables")
-public class SubscribableDefinition implements Serializable {
-
- private static final long serialVersionUID = 963835780151323701L;
-
- private String type;
-
- private String alias;
-
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java
deleted file mode 100644
index c98233c..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java
+++ /dev/null
@@ -1,131 +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.manager.composite.application.beans;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "subscribableInfo")
-public class SubscribableInfo implements Serializable {
-
- private static final long serialVersionUID = 8097432440778125606L;
-
- private String alias;
- private String deploymentPolicy;
- private String autoscalingPolicy;
- private String repoUrl;
- private boolean privateRepo;
- private String repoUsername;
- private int maxMembers;
- private int minMembers;
- private String repoPassword;
- private String[] dependencyAliases;
- private List<PropertyBean> property;
-
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public String getDeploymentPolicy() {
- return deploymentPolicy;
- }
-
- public void setDeploymentPolicy(String deploymentPolicy) {
- this.deploymentPolicy = deploymentPolicy;
- }
-
- public String getAutoscalingPolicy() {
- return autoscalingPolicy;
- }
-
- public void setAutoscalingPolicy(String autoscalingPolicy) {
- this.autoscalingPolicy = autoscalingPolicy;
- }
-
- public String getRepoUrl() {
- return repoUrl;
- }
-
- public void setRepoUrl(String repoUrl) {
- this.repoUrl = repoUrl;
- }
-
- public boolean isPrivateRepo() {
- return privateRepo;
- }
-
- public void setPrivateRepo(boolean privateRepo) {
- this.privateRepo = privateRepo;
- }
-
- public String getRepoUsername() {
- return repoUsername;
- }
-
- public void setRepoUsername(String repoUsername) {
- this.repoUsername = repoUsername;
- }
-
- public String getRepoPassword() {
- return repoPassword;
- }
-
- public void setRepoPassword(String repoPassword) {
- this.repoPassword = repoPassword;
- }
-
- public String[] getDependencyAliases() {
- return dependencyAliases;
- }
-
- public void setDependencyAliases(String[] dependencyAliases) {
- this.dependencyAliases = dependencyAliases;
- }
-
- public List<PropertyBean> getProperty() {
- return property;
- }
-
- public void setProperty(List<PropertyBean> property) {
- this.property = property;
- }
-
- public int getMaxMembers() {
- return maxMembers;
- }
-
- public void setMaxMembers(int maxMembers) {
- this.maxMembers = maxMembers;
- }
-
- public int getMinMembers() {
- return minMembers;
- }
-
- public void setMinMembers(int minMembers) {
- this.minMembers = minMembers;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnector.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnector.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnector.java
deleted file mode 100644
index bf7d0d7..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnector.java
+++ /dev/null
@@ -1,45 +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.manager.connector;
-
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-
-import java.util.Properties;
-
-public abstract class CartridgeSubscriptionConnector {
-
- /**
- * Connects two CartridgeSubscription instances
- *
- * @param cartridgeSubscription CartridgeSubscription subscription
- * @param connectingCartridgeSubscription CartridgeSubscription subscription that is connecting with cartridgeSubscription
- *
- * @return Custom properties for the connection as a key value set
- * @throws ADCException in case of an error
- */
- public abstract Properties createConnection (CartridgeSubscription cartridgeSubscription,
- CartridgeSubscription connectingCartridgeSubscription)
- throws ADCException;
-
- public abstract Properties teminateConnection (CartridgeSubscription cartridgeSubscription,
- CartridgeSubscription connectedCartridgeSubscription)
- throws ADCException;
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnectorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnectorFactory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnectorFactory.java
deleted file mode 100644
index b0719e7..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/connector/CartridgeSubscriptionConnectorFactory.java
+++ /dev/null
@@ -1,41 +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.manager.connector;
-
-import org.apache.stratos.manager.connector.data.DataCartridgeSubscriptionConnector;
-import org.apache.stratos.manager.exception.ADCException;
-
-public class CartridgeSubscriptionConnectorFactory {
-
- public static CartridgeSubscriptionConnector getCartridgeInstanceConnector (String type) throws ADCException {
-
- CartridgeSubscriptionConnector cartridgeSubscriptionConnector = null;
-
- if(type.equals("mysql")) {
- cartridgeSubscriptionConnector = new DataCartridgeSubscriptionConnector();
- }
-
- if(cartridgeSubscriptionConnector == null) {
- throw new ADCException("Unable to find matching CartridgeSubscriptionConnector for " + type);
- }
-
- return cartridgeSubscriptionConnector;
- }
-}
[10/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java
deleted file mode 100644
index d6934a9..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java
+++ /dev/null
@@ -1,64 +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.manager.grouping.definitions;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.List;
-
-@XmlRootElement(name = "dependencies")
-public class DependencyDefinitions implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private List<String> startupOrders;
-
- private List<String> scalingDependants;
-
- private String terminationBehaviour;
-
- public String getTerminationBehaviour() {
- return terminationBehaviour;
- }
-
- public void setTerminationBehaviour(String terminationBehaviour) {
- this.terminationBehaviour = terminationBehaviour;
- }
-
- public List<String> getStartupOrders() {
- return startupOrders;
- }
-
- public void setStartupOrders(List<String> startupOrders) {
- this.startupOrders = startupOrders;
- }
-
- public List<String> getScalingDependants() {
- return scalingDependants;
- }
-
- public void setScalingDependants(List<String> scalingDependants) {
- this.scalingDependants = scalingDependants;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java
deleted file mode 100644
index 58d5963..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java
+++ /dev/null
@@ -1,70 +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.manager.grouping.definitions;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-import java.util.List;
-
-@XmlRootElement(name = "groups")
-public class ServiceGroupDefinition implements Serializable {
-
- private String name;
-
- private List<ServiceGroupDefinition> groups;
-
- private List<String> cartridges;
-
- public boolean isGroupScalingEnabled;
-
- private DependencyDefinitions dependencies;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<String> getCartridges() {
- return cartridges;
- }
-
- public void setCartridges(List<String> cartridges) {
- this.cartridges = cartridges;
- }
-
- public DependencyDefinitions getDependencies() {
- return dependencies;
- }
-
- public void setDependencies(DependencyDefinitions dependencies) {
- this.dependencies = dependencies;
- }
-
- public List<ServiceGroupDefinition> getGroups() {
- return groups;
- }
-
- public void setGroups(List<ServiceGroupDefinition> groups) {
- this.groups = groups;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java
deleted file mode 100644
index 522e3a2..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java
+++ /dev/null
@@ -1,47 +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.manager.grouping.definitions;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.io.Serializable;
-
-@XmlRootElement(name = "startupOrder")
-public class StartupOrderDefinition implements Serializable {
-
- private String start;
-
- private String after;
-
- public String getStart() {
- return start;
- }
-
- public void setStart(String start) {
- this.start = start;
- }
-
- public String getAfter() {
- return after;
- }
-
- public void setAfter(String after) {
- this.after = after;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
deleted file mode 100644
index e737d23..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java
+++ /dev/null
@@ -1,409 +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.manager.grouping.deployer;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.stub.AutoScalerServiceAutoScalerExceptionException;
-import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidServiceGroupExceptionException;
-import org.apache.stratos.autoscaler.stub.pojo.Dependencies;
-import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup;
-import org.apache.stratos.cloud.controller.stub.CloudControllerServiceCartridgeNotFoundExceptionException;
-import org.apache.stratos.manager.client.AutoscalerServiceClient;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.InvalidServiceGroupException;
-import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
-import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-
-import java.rmi.RemoteException;
-import java.util.*;
-
-public class DefaultServiceGroupDeployer implements ServiceGroupDeployer {
-
- private static Log log = LogFactory.getLog(DefaultServiceGroupDeployer.class);
-
-
- public DefaultServiceGroupDeployer() {
- }
-
- public void deployServiceGroupDefinition(Object serviceGroupDefinitionObj) throws InvalidServiceGroupException, ServiceGroupDefinitioException, ADCException {
-
- ServiceGroupDefinition serviceGroupDefinition = null;
- ServiceGroup serviceGroup = null;
-
- if (serviceGroupDefinitionObj == null) {
- if (log.isDebugEnabled()) {
- log.debug("deploying service group is null ");
- }
- throw new InvalidServiceGroupException("Service Group definition not found");
- }
-
- if (serviceGroupDefinitionObj instanceof ServiceGroupDefinition) {
- serviceGroupDefinition = (ServiceGroupDefinition) serviceGroupDefinitionObj;
-
- if (log.isDebugEnabled()) {
- log.debug("deploying service group with name " + serviceGroupDefinition.getName());
- }
-
- // convert serviceGroupDefinition to serviceGroup
- serviceGroup = this.populateServiceGroupPojo(serviceGroupDefinition);
- } else {
- log.error("trying to deploy invalid service group ");
- throw new InvalidServiceGroupException("Invalid Service Group definition");
- }
-
- // if any cartridges are specified in the group, they should be already deployed
- if (serviceGroupDefinition.getCartridges() != null) {
-
- if (log.isDebugEnabled()) {
- log.debug("checking cartridges in service group " + serviceGroupDefinition.getName());
- }
-
- List<String> cartridgeTypes = serviceGroupDefinition.getCartridges();
-
- Set<String> duplicates = this.findDuplicates(cartridgeTypes);
-
- if (duplicates.size() > 0) {
-
- StringBuffer buf = new StringBuffer();
- for (String dup : duplicates) {
- buf.append(dup).append(" ");
- }
- if (log.isDebugEnabled()) {
- log.debug("duplicate cartridges defined: " + buf.toString());
- }
- throw new InvalidServiceGroupException("Invalid Service Group definition, duplicate cartridges defined:" + buf.toString());
- }
-
- CloudControllerServiceClient ccServiceClient = null;
-
- try {
- ccServiceClient = CloudControllerServiceClient.getServiceClient();
-
- } catch (AxisFault axisFault) {
- throw new ADCException(axisFault);
- }
-
- for (String cartridgeType : cartridgeTypes) {
- try {
- if (ccServiceClient.getCartridgeInfo(cartridgeType) == null) {
- // cartridge is not deployed, can't continue
- log.error("invalid cartridge found in service group " + cartridgeType);
- throw new InvalidServiceGroupException("No Cartridge Definition found with type " + cartridgeType);
- }
- } catch (RemoteException e) {
- throw new ADCException(e);
- } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
- throw new ADCException(e);
- }
- }
- }
-
- // if any sub groups are specified in the group, they should be already deployed
- if (serviceGroupDefinition.getGroups() != null) {
-
- if (log.isDebugEnabled()) {
- log.debug("checking subGroups in service group " + serviceGroupDefinition.getName());
- }
-
- List<ServiceGroupDefinition> groupDefinitions = serviceGroupDefinition.getGroups();
- List<String> groupNames = new ArrayList<String>();
- for (ServiceGroupDefinition groupList : groupDefinitions) {
- groupNames.add(groupList.getName());
- }
-
- Set<String> duplicates = this.findDuplicates(groupNames);
-
- if (duplicates.size() > 0) {
-
- StringBuffer buf = new StringBuffer();
- for (String dup : duplicates) {
- buf.append(dup).append(" ");
- }
- if (log.isDebugEnabled()) {
- log.debug("duplicate subGroups defined: " + buf.toString());
- }
- throw new InvalidServiceGroupException("Invalid Service Group definition, duplicate subGroups defined:" + buf.toString());
- }
-
-// for (String subGroupName : groupNames) {
-// if (getServiceGroupDefinition(subGroupName) == null) {
-// // sub group not deployed, can't continue
-// if (log.isDebugEnabled()) {
-// log.debug("invalid sub group found in service group " + subGroupName);
-// }
-// throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName);
-// }
-// }
- }
-
- AutoscalerServiceClient asServiceClient = null;
-
- try {
- asServiceClient = AutoscalerServiceClient.getServiceClient();
-
- if (log.isDebugEnabled()) {
- log.debug("deplying to cloud controller service group " + serviceGroupDefinition.getName());
- }
-
- asServiceClient.addServiceGroup(serviceGroup);
-
- } catch (AxisFault axisFault) {
- throw new ADCException(axisFault);
- } catch (RemoteException e) {
- throw new ADCException(e);
- } catch (AutoScalerServiceInvalidServiceGroupExceptionException e) {
- e.printStackTrace();
- }
- }
-
- public ServiceGroupDefinition getServiceGroupDefinition(String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException {
-
- if (log.isDebugEnabled()) {
- log.debug("getting service group from cloud controller " + serviceGroupDefinitionName);
- }
-
- AutoscalerServiceClient asServiceClient = null;
-
- try {
- asServiceClient = AutoscalerServiceClient.getServiceClient();
-
- if (log.isDebugEnabled()) {
- log.debug(String.format("Calling AS to get service group %s", serviceGroupDefinitionName));
- }
-
- ServiceGroup serviceGroup = asServiceClient.getServiceGroup(serviceGroupDefinitionName);
- if (serviceGroup == null) {
- return null;
- }
-
- ServiceGroupDefinition serviceGroupDef = convertServiceGroupToServiceGroupDefinition(serviceGroup);
- return serviceGroupDef;
-
- } catch (AxisFault axisFault) {
- throw new ADCException(axisFault);
- } catch (RemoteException e) {
- throw new ADCException(e);
- }
- }
-
- public ServiceGroupDefinition[] getServiceGroupDefinitions() throws ADCException {
-
- if (log.isDebugEnabled()) {
- log.debug("getting service group from cloud controller ");
- }
-
- AutoscalerServiceClient asServiceClient;
-
- try {
- asServiceClient = AutoscalerServiceClient.getServiceClient();
-
- ServiceGroup[] serviceGroups = asServiceClient.getServiceGroups();
- if (serviceGroups == null || serviceGroups.length == 0) {
- return null;
- }
-
- ServiceGroupDefinition[] serviceGroupDefinitions = new ServiceGroupDefinition[serviceGroups.length];
- for (int i = 0; i < serviceGroups.length; i++) {
- serviceGroupDefinitions[i] = convertServiceGroupToServiceGroupDefinition(serviceGroups[i]);
- }
- return serviceGroupDefinitions;
-
- } catch (AxisFault axisFault) {
- throw new ADCException(axisFault);
- } catch (RemoteException e) {
- throw new ADCException(e);
- } catch (AutoScalerServiceAutoScalerExceptionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
- }
-
-
- public void undeployServiceGroupDefinition(String name) throws ADCException, ServiceGroupDefinitioException {
-
- //throw new ServiceGroupDefinitioException("method not supported");
-
- AutoscalerServiceClient autoscalerServiceClient = null;
-
- try {
- autoscalerServiceClient = AutoscalerServiceClient.getServiceClient();
-
- if (log.isDebugEnabled()) {
- log.debug("undeploying service group from cloud controller " + name);
- }
-
- autoscalerServiceClient.undeployServiceGroupDefinition(name);
-
- } catch (AxisFault axisFault) {
- throw new ADCException(axisFault);
- } catch (RemoteException e) {
- throw new ADCException(e);
- } catch (AutoScalerServiceAutoScalerExceptionException e) {
- throw new ADCException(e);
- }
- }
-
-
- private ServiceGroup populateServiceGroupPojo(ServiceGroupDefinition serviceGroupDefinition) throws ServiceGroupDefinitioException {
- ServiceGroup servicegroup = new ServiceGroup();
-
- // implement conversion (mostly List -> Array)
- servicegroup.setGroupscalingEnabled(serviceGroupDefinition.isGroupScalingEnabled);
- List<ServiceGroupDefinition> groupsDef = serviceGroupDefinition.getGroups();
- List<String> cartridgesDef = serviceGroupDefinition.getCartridges();
-
- servicegroup.setName(serviceGroupDefinition.getName());
-
- if (groupsDef == null) {
- groupsDef = new ArrayList<ServiceGroupDefinition>(0);
- }
-
- if (cartridgesDef == null) {
- cartridgesDef = new ArrayList<String>(0);
- }
-
- ServiceGroup[] subGroups = new ServiceGroup[groupsDef.size()];
- String[] cartridges = new String[cartridgesDef.size()];
-
- int i = 0;
- for (ServiceGroupDefinition groupDefinition : groupsDef) {
- subGroups[i] = populateServiceGroupPojo(groupDefinition);
- ++i;
- }
-
- servicegroup.setGroups(subGroups);
- cartridges = cartridgesDef.toArray(cartridges);
- servicegroup.setCartridges(cartridges);
-
- DependencyDefinitions depDefs = serviceGroupDefinition.getDependencies();
-
- if (depDefs != null) {
- Dependencies deps = new Dependencies();
- List<String> startupOrdersDef = depDefs.getStartupOrders();
- if (startupOrdersDef != null) {
- String[] startupOrders = new String[startupOrdersDef.size()];
- startupOrders = startupOrdersDef.toArray(startupOrders);
- deps.setStartupOrders(startupOrders);
- }
- // validate termination behavior
- validateTerminationBehavior(depDefs.getTerminationBehaviour());
- deps.setTerminationBehaviour(depDefs.getTerminationBehaviour());
- if (depDefs.getScalingDependants() != null) {
- deps.setScalingDependants(depDefs.getScalingDependants()
- .toArray(new String[depDefs.getScalingDependants().size()]));
- }
- servicegroup.setDependencies(deps);
- }
-
- return servicegroup;
- }
-
- private ServiceGroupDefinition convertServiceGroupToServiceGroupDefinition(ServiceGroup serviceGroup) {
- if(serviceGroup == null) {
- return null;
- }
-
- ServiceGroupDefinition servicegroupDef = new ServiceGroupDefinition();
- servicegroupDef.setName(serviceGroup.getName());
- String[] cartridges = serviceGroup.getCartridges();
- ServiceGroup[] groups = serviceGroup.getGroups();
- org.apache.stratos.autoscaler.stub.pojo.Dependencies deps = serviceGroup.getDependencies();
-
- List<ServiceGroupDefinition> groupDefinitions = new ArrayList<ServiceGroupDefinition>(groups.length);
- for (ServiceGroup group : groups) {
- if (group != null) {
- groupDefinitions.add(convertServiceGroupToServiceGroupDefinition(group));
- }
- }
-
- if (deps != null) {
- DependencyDefinitions depsDef = new DependencyDefinitions();
- String[] startupOrders = deps.getStartupOrders();
- if (startupOrders != null && startupOrders[0] != null) {
- List<String> startupOrdersDef = Arrays.asList(startupOrders);
- depsDef.setStartupOrders(startupOrdersDef);
- }
-
- String [] scalingDependants = deps.getScalingDependants();
- if (scalingDependants != null && scalingDependants[0] != null) {
- List<String> scalingDependenciesDef = Arrays.asList(scalingDependants);
- depsDef.setScalingDependants(scalingDependenciesDef);
- }
-
- depsDef.setTerminationBehaviour(deps.getTerminationBehaviour());
- servicegroupDef.setDependencies(depsDef);
- }
-
- List<String> cartridgesDef = new ArrayList<String>(Arrays.asList(cartridges));
- //List<ServiceGroupDefinition> subGroupsDef = new ArrayList<ServiceGroupDefinition>(groups.length);
- if (cartridges[0] != null) {
- servicegroupDef.setCartridges(cartridgesDef);
- }
- if (groups != null) {
- servicegroupDef.setGroups(groupDefinitions);
- }
-
- return servicegroupDef;
- }
-
- /**
- * Validates terminationBehavior. The terminationBehavior should be one of the following:
- * 1. terminate-none
- * 2. terminate-dependents
- * 3. terminate-all
- *
- * @throws ServiceGroupDefinitioException if terminationBehavior is different to what is
- * listed above
- */
- private static void validateTerminationBehavior(String terminationBehavior) throws ServiceGroupDefinitioException {
-
- if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) ||
- "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) {
- throw new ServiceGroupDefinitioException("Invalid Termination Behaviour specified: [ " +
- terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " +
- " 'terminate-all' ");
- }
- }
-
- /**
- * returns any duplicates in a List
- *
- * @param checkedList
- * @return
- */
- private Set<String> findDuplicates(List<String> checkedList) {
- final Set<String> retVals = new HashSet<String>();
- final Set<String> set1 = new HashSet<String>();
-
- for (String val : checkedList) {
-
- if (!set1.add(val)) {
- retVals.add(val);
- }
- }
- return retVals;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java
deleted file mode 100644
index 8d5653f..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java
+++ /dev/null
@@ -1,38 +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.manager.grouping.deployer;
-
-import org.apache.stratos.cloud.controller.stub.CloudControllerServiceCartridgeNotFoundExceptionException;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.InvalidServiceGroupException;
-import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-
-public interface ServiceGroupDeployer {
-
- public void deployServiceGroupDefinition(Object serviceGroupObj) throws InvalidServiceGroupException, ServiceGroupDefinitioException,
- ADCException, CloudControllerServiceCartridgeNotFoundExceptionException;
-
- public ServiceGroupDefinition getServiceGroupDefinition(String serviceGroupDefinitionName) throws ServiceGroupDefinitioException, ADCException;
-
- public void undeployServiceGroupDefinition(String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException;
-
- ServiceGroupDefinition[] getServiceGroupDefinitions() throws ADCException;
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
deleted file mode 100644
index 8698122..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java
+++ /dev/null
@@ -1,60 +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.manager.grouping.manager;
-
-import org.apache.stratos.cloud.controller.stub.CloudControllerServiceCartridgeNotFoundExceptionException;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.InvalidServiceGroupException;
-import org.apache.stratos.manager.exception.ServiceGroupDefinitioException;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.grouping.deployer.DefaultServiceGroupDeployer;
-import org.apache.stratos.manager.grouping.deployer.ServiceGroupDeployer;
-
-
-public class ServiceGroupingManager {
-
- //private static Log log = LogFactory.getLog(ServiceGroupingManager.class);
- private ServiceGroupDeployer serviceGroupDeployer;
-
- public ServiceGroupingManager() {
- serviceGroupDeployer = new DefaultServiceGroupDeployer();
- }
-
- public void deployServiceGroupDefinition(ServiceGroupDefinition serviceGroupDefinition) throws InvalidServiceGroupException,
- CloudControllerServiceCartridgeNotFoundExceptionException, ServiceGroupDefinitioException, ADCException {
-
- serviceGroupDeployer.deployServiceGroupDefinition(serviceGroupDefinition);
- }
-
- public ServiceGroupDefinition getServiceGroupDefinition(String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException {
-
- return serviceGroupDeployer.getServiceGroupDefinition(serviceGroupDefinitionName);
- }
-
- public ServiceGroupDefinition[] getServiceGroupDefinitions() throws ADCException, ServiceGroupDefinitioException {
-
- return serviceGroupDeployer.getServiceGroupDefinitions();
- }
-
- public void undeployServiceGroupDefinition(String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException {
-
- serviceGroupDeployer.undeployServiceGroupDefinition(serviceGroupDefinitionName);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
deleted file mode 100644
index ae4a2c2..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ADCManagementServerComponent.java
+++ /dev/null
@@ -1,200 +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.manager.internal;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.threading.StratosThreadPool;
-import org.apache.stratos.manager.listener.StratosManagerInstanceStatusEventReceiver;
-import org.apache.stratos.manager.listener.TenantUserRoleCreator;
-import org.apache.stratos.manager.publisher.TenantEventPublisher;
-import org.apache.stratos.manager.publisher.TenantSynchronizerTaskScheduler;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.topology.receiver.StratosManagerTopologyEventReceiver;
-import org.apache.stratos.manager.utils.CartridgeConfigFileReader;
-import org.apache.stratos.manager.utils.UserRoleCreator;
-import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
-import org.apache.stratos.messaging.util.Util;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.ntask.core.service.TaskService;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.user.api.UserStoreManager;
-import org.wso2.carbon.user.core.UserRealm;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.ConfigurationContextService;
-
-import java.util.concurrent.ExecutorService;
-
-/**
- * @scr.component name="org.wso2.carbon.hosting.mgt.internal.ADCManagementServerComponent"
- * immediate="true"
- * @scr.reference name="config.context.service"
- * interface="org.wso2.carbon.utils.ConfigurationContextService"
- * cardinality="1..1" policy="dynamic"
- * bind="setConfigurationContextService"
- * unbind="unsetConfigurationContextService"
- * @scr.reference name="user.realmservice.default"
- * interface="org.wso2.carbon.user.core.service.RealmService"
- * cardinality="1..1" policy="dynamic" bind="setRealmService"
- * unbind="unsetRealmService"
- * @scr.reference name="registry.service"
- * interface=
- * "org.wso2.carbon.registry.core.service.RegistryService"
- * cardinality="1..1" policy="dynamic" bind="setRegistryService"
- * unbind="unsetRegistryService"
- * @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService"
- * cardinality="1..1" policy="dynamic" bind="setTaskService"
- * unbind="unsetTaskService"
- */
-
-public class ADCManagementServerComponent {
-
- private static final Log log = LogFactory.getLog(ADCManagementServerComponent.class);
- private static final String IDENTIFIER = "Stratos_manager";
- private static final int THREAD_POOL_SIZE = 20;
-
- private StratosManagerTopologyEventReceiver topologyEventReceiver;
- private StratosManagerInstanceStatusEventReceiver instanceStatusEventReceiver;
- private ExecutorService executorService;
-
- protected void activate(ComponentContext componentContext) throws Exception {
- try {
- CartridgeConfigFileReader.readProperties();
- executorService=StratosThreadPool.getExecutorService(IDENTIFIER, THREAD_POOL_SIZE);
-
- // Schedule complete tenant event synchronizer
- if(log.isDebugEnabled()) {
- log.debug("Scheduling tenant synchronizer task...");
- }
- TenantSynchronizerTaskScheduler.schedule(ServiceReferenceHolder.getInstance().getTaskService());
-
- // Register tenant event publisher
- if(log.isDebugEnabled()) {
- log.debug("Starting tenant event publisher...");
- }
- TenantEventPublisher tenantEventPublisher = new TenantEventPublisher();
- componentContext.getBundleContext().registerService(
- org.apache.stratos.common.listeners.TenantMgtListener.class.getName(),
- tenantEventPublisher, null);
-
- if(log.isDebugEnabled()) {
- log.debug("Starting instance status event receiver...");
- }
- instanceStatusEventReceiver = new StratosManagerInstanceStatusEventReceiver();
- instanceStatusEventReceiver.setExecutorService(executorService);
- instanceStatusEventReceiver.execute();
- if(log.isInfoEnabled()) {
- log.info("Instance status event receiver thread started");
- }
-
- if(log.isDebugEnabled()) {
- log.debug("Starting topology event receiver...");
- }
- topologyEventReceiver = new StratosManagerTopologyEventReceiver();
- topologyEventReceiver.setExecutorService(executorService);
- executorService.execute(topologyEventReceiver);
- if(log.isInfoEnabled()) {
- log.info("Topology event receiver thread started");
- }
-
- RealmService realmService = DataHolder.getRealmService();
- UserRealm realm = realmService.getBootstrapRealm();
- UserStoreManager userStoreManager = realm.getUserStoreManager();
- //Create a Internal/user Role at server start-up
- UserRoleCreator.createTenantUserRole(userStoreManager);
-
- TenantUserRoleCreator tenantUserRoleCreator = new TenantUserRoleCreator();
- componentContext.getBundleContext().registerService(
- org.apache.stratos.common.listeners.TenantMgtListener.class.getName(),
- tenantUserRoleCreator, null);
-
- // retrieve persisted CartridgeSubscriptions
- new DataInsertionAndRetrievalManager().cachePersistedSubscriptions();
-
- //Component activated successfully
- log.info("ADC management server component is activated");
-
- } catch (Exception e) {
- if(log.isErrorEnabled()) {
- log.error("Could not activate ADC management server component", e);
- }
- }
- }
-
- protected void setConfigurationContextService(ConfigurationContextService contextService) {
- DataHolder.setClientConfigContext(contextService.getClientConfigContext());
- DataHolder.setServerConfigContext(contextService.getServerConfigContext());
-
- }
-
- protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
- DataHolder.setClientConfigContext(null);
- DataHolder.setServerConfigContext(null);
- }
-
- protected void setRealmService(RealmService realmService) {
- // keeping the realm service in the DataHolder class
- DataHolder.setRealmService(realmService);
- }
-
- protected void unsetRealmService(RealmService realmService) {
- }
-
- protected void setRegistryService(RegistryService registryService) {
- try {
- DataHolder.setRegistryService(registryService);
- } catch (Exception e) {
- log.error("Cannot retrieve governance registry", e);
- }
- }
-
- protected void unsetRegistryService(RegistryService registryService) {
- }
-
- /*protected void setTopologyManagementService(TopologyManagementService topologyMgtService) {
- DataHolder.setTopologyMgtService(topologyMgtService);
- }
-
- protected void unsetTopologyManagementService(TopologyManagementService topologyMgtService) {
- }*/
-
- protected void setTaskService(TaskService taskService) {
- if (log.isDebugEnabled()) {
- log.debug("Setting the task service");
- }
- ServiceReferenceHolder.getInstance().setTaskService(taskService);
- }
-
- protected void unsetTaskService(TaskService taskService) {
- if (log.isDebugEnabled()) {
- log.debug("Un-setting the task service");
- }
- ServiceReferenceHolder.getInstance().setTaskService(null);
- }
-
- protected void deactivate(ComponentContext context) {
- // Close event publisher connections to message broker
- EventPublisherPool.close(Util.Topics.INSTANCE_NOTIFIER_TOPIC.getTopicName());
- EventPublisherPool.close(Util.Topics.TENANT_TOPIC.getTopicName());
-
- executorService.shutdownNow();
- //terminate Stratos Manager Topology Receiver
- topologyEventReceiver.terminate();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/DataHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/DataHolder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/DataHolder.java
deleted file mode 100644
index 07f21de..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/DataHolder.java
+++ /dev/null
@@ -1,70 +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.manager.internal;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.utils.CarbonUtils;
-
-/**
- * Holds the some of the data required by the webapps component
- */
-public class DataHolder {
- private static ConfigurationContext clientConfigContext;
- private static ConfigurationContext serverConfigContext;
-
- private static RealmService realmService;
- private static RegistryService registryService;
-
- public static RealmService getRealmService() {
- return realmService;
- }
-
- public static void setRealmService(RealmService realmService) {
- DataHolder.realmService = realmService;
- }
-
- public static RegistryService getRegistryService() {
- return registryService;
- }
-
- public static ConfigurationContext getClientConfigContext() {
- CarbonUtils.checkSecurity();
- return clientConfigContext;
- }
-
- public static void setClientConfigContext(ConfigurationContext clientConfigContext) {
- DataHolder.clientConfigContext = clientConfigContext;
- }
-
- public static ConfigurationContext getServerConfigContext() {
- CarbonUtils.checkSecurity();
- return serverConfigContext;
- }
-
- public static void setServerConfigContext(ConfigurationContext serverConfigContext) {
- DataHolder.serverConfigContext = serverConfigContext;
- }
-
- public static void setRegistryService(RegistryService registryService) {
- DataHolder.registryService = registryService;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
index c5b75bd..a394e08 100644
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/ServiceReferenceHolder.java
@@ -19,13 +19,22 @@
package org.apache.stratos.manager.internal;
+import org.apache.axis2.context.ConfigurationContext;
import org.wso2.carbon.ntask.core.service.TaskService;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.CarbonUtils;
/**
* Service reference holder.
*/
public class ServiceReferenceHolder {
private static volatile ServiceReferenceHolder instance = null;
+
+ private static ConfigurationContext clientConfigContext;
+ private static ConfigurationContext serverConfigContext;
+ private static RealmService realmService;
+ private static RegistryService registryService;
private TaskService taskService;
private ServiceReferenceHolder() { }
@@ -41,6 +50,40 @@ public class ServiceReferenceHolder {
return instance;
}
+ public static RealmService getRealmService() {
+ return realmService;
+ }
+
+ public static void setRealmService(RealmService realmService) {
+ ServiceReferenceHolder.realmService = realmService;
+ }
+
+ public static RegistryService getRegistryService() {
+ return registryService;
+ }
+
+ public static ConfigurationContext getClientConfigContext() {
+ CarbonUtils.checkSecurity();
+ return clientConfigContext;
+ }
+
+ public static void setClientConfigContext(ConfigurationContext clientConfigContext) {
+ ServiceReferenceHolder.clientConfigContext = clientConfigContext;
+ }
+
+ public static ConfigurationContext getServerConfigContext() {
+ CarbonUtils.checkSecurity();
+ return serverConfigContext;
+ }
+
+ public static void setServerConfigContext(ConfigurationContext serverConfigContext) {
+ ServiceReferenceHolder.serverConfigContext = serverConfigContext;
+ }
+
+ public static void setRegistryService(RegistryService registryService) {
+ ServiceReferenceHolder.registryService = registryService;
+ }
+
public void setTaskService(TaskService taskService) {
this.taskService = taskService;
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java
new file mode 100644
index 0000000..2cab71f
--- /dev/null
+++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/internal/StratosManagerServiceComponent.java
@@ -0,0 +1,199 @@
+/*
+ * 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.manager.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.common.threading.StratosThreadPool;
+import org.apache.stratos.manager.messaging.receiver.StratosManagerInstanceStatusEventReceiver;
+import org.apache.stratos.manager.user.management.TenantUserRoleManager;
+import org.apache.stratos.manager.messaging.publisher.TenantEventPublisher;
+import org.apache.stratos.manager.messaging.TenantSynchronizerTaskScheduler;
+import org.apache.stratos.manager.messaging.receiver.StratosManagerTopologyEventReceiver;
+import org.apache.stratos.manager.utils.CartridgeConfigFileReader;
+import org.apache.stratos.manager.utils.UserRoleCreator;
+import org.apache.stratos.messaging.broker.publish.EventPublisherPool;
+import org.apache.stratos.messaging.util.Util;
+import org.osgi.service.component.ComponentContext;
+import org.wso2.carbon.ntask.core.service.TaskService;
+import org.wso2.carbon.registry.core.service.RegistryService;
+import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.core.UserRealm;
+import org.wso2.carbon.user.core.service.RealmService;
+import org.wso2.carbon.utils.ConfigurationContextService;
+
+import java.util.concurrent.ExecutorService;
+
+/**
+ * @scr.component name="org.wso2.carbon.hosting.mgt.internal.StratosManagerServiceComponent"
+ * immediate="true"
+ * @scr.reference name="config.context.service"
+ * interface="org.wso2.carbon.utils.ConfigurationContextService"
+ * cardinality="1..1" policy="dynamic"
+ * bind="setConfigurationContextService"
+ * unbind="unsetConfigurationContextService"
+ * @scr.reference name="user.realmservice.default"
+ * interface="org.wso2.carbon.user.core.service.RealmService"
+ * cardinality="1..1" policy="dynamic" bind="setRealmService"
+ * unbind="unsetRealmService"
+ * @scr.reference name="registry.service"
+ * interface=
+ * "org.wso2.carbon.registry.core.service.RegistryService"
+ * cardinality="1..1" policy="dynamic" bind="setRegistryService"
+ * unbind="unsetRegistryService"
+ * @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService"
+ * cardinality="1..1" policy="dynamic" bind="setTaskService"
+ * unbind="unsetTaskService"
+ */
+
+public class StratosManagerServiceComponent {
+
+ private static final Log log = LogFactory.getLog(StratosManagerServiceComponent.class);
+ private static final String IDENTIFIER = "Stratos_manager";
+ private static final int THREAD_POOL_SIZE = 20;
+
+ private StratosManagerTopologyEventReceiver topologyEventReceiver;
+ private StratosManagerInstanceStatusEventReceiver instanceStatusEventReceiver;
+ private ExecutorService executorService;
+
+ protected void activate(ComponentContext componentContext) throws Exception {
+ try {
+ CartridgeConfigFileReader.readProperties();
+ executorService=StratosThreadPool.getExecutorService(IDENTIFIER, THREAD_POOL_SIZE);
+
+ // Schedule complete tenant event synchronizer
+ if(log.isDebugEnabled()) {
+ log.debug("Scheduling tenant synchronizer task...");
+ }
+ TenantSynchronizerTaskScheduler.schedule(ServiceReferenceHolder.getInstance().getTaskService());
+
+ // Register tenant event publisher
+ if(log.isDebugEnabled()) {
+ log.debug("Starting tenant event publisher...");
+ }
+ TenantEventPublisher tenantEventPublisher = new TenantEventPublisher();
+ componentContext.getBundleContext().registerService(
+ org.apache.stratos.common.listeners.TenantMgtListener.class.getName(),
+ tenantEventPublisher, null);
+
+ if(log.isDebugEnabled()) {
+ log.debug("Starting instance status event receiver...");
+ }
+ instanceStatusEventReceiver = new StratosManagerInstanceStatusEventReceiver();
+ instanceStatusEventReceiver.setExecutorService(executorService);
+ instanceStatusEventReceiver.execute();
+ if(log.isInfoEnabled()) {
+ log.info("Instance status event receiver thread started");
+ }
+
+ if(log.isDebugEnabled()) {
+ log.debug("Starting topology event receiver...");
+ }
+ topologyEventReceiver = new StratosManagerTopologyEventReceiver();
+ topologyEventReceiver.setExecutorService(executorService);
+ executorService.execute(topologyEventReceiver);
+ if(log.isInfoEnabled()) {
+ log.info("Topology event receiver thread started");
+ }
+
+ RealmService realmService = ServiceReferenceHolder.getRealmService();
+ UserRealm realm = realmService.getBootstrapRealm();
+ UserStoreManager userStoreManager = realm.getUserStoreManager();
+ //Create a Internal/user Role at server start-up
+ UserRoleCreator.createTenantUserRole(userStoreManager);
+
+ TenantUserRoleManager tenantUserRoleManager = new TenantUserRoleManager();
+ componentContext.getBundleContext().registerService(
+ org.apache.stratos.common.listeners.TenantMgtListener.class.getName(),
+ tenantUserRoleManager, null);
+
+ // retrieve persisted CartridgeSubscriptions
+// new DataInsertionAndRetrievalManager().cachePersistedSubscriptions();
+
+ //Component activated successfully
+ log.info("ADC management server component is activated");
+
+ } catch (Exception e) {
+ if(log.isErrorEnabled()) {
+ log.error("Could not activate ADC management server component", e);
+ }
+ }
+ }
+
+ protected void setConfigurationContextService(ConfigurationContextService contextService) {
+ ServiceReferenceHolder.setClientConfigContext(contextService.getClientConfigContext());
+ ServiceReferenceHolder.setServerConfigContext(contextService.getServerConfigContext());
+
+ }
+
+ protected void unsetConfigurationContextService(ConfigurationContextService contextService) {
+ ServiceReferenceHolder.setClientConfigContext(null);
+ ServiceReferenceHolder.setServerConfigContext(null);
+ }
+
+ protected void setRealmService(RealmService realmService) {
+ // keeping the realm service in the DataHolder class
+ ServiceReferenceHolder.setRealmService(realmService);
+ }
+
+ protected void unsetRealmService(RealmService realmService) {
+ }
+
+ protected void setRegistryService(RegistryService registryService) {
+ try {
+ ServiceReferenceHolder.setRegistryService(registryService);
+ } catch (Exception e) {
+ log.error("Cannot retrieve governance registry", e);
+ }
+ }
+
+ protected void unsetRegistryService(RegistryService registryService) {
+ }
+
+ /*protected void setTopologyManagementService(TopologyManagementService topologyMgtService) {
+ DataHolder.setTopologyMgtService(topologyMgtService);
+ }
+
+ protected void unsetTopologyManagementService(TopologyManagementService topologyMgtService) {
+ }*/
+
+ protected void setTaskService(TaskService taskService) {
+ if (log.isDebugEnabled()) {
+ log.debug("Setting the task service");
+ }
+ ServiceReferenceHolder.getInstance().setTaskService(taskService);
+ }
+
+ protected void unsetTaskService(TaskService taskService) {
+ if (log.isDebugEnabled()) {
+ log.debug("Un-setting the task service");
+ }
+ ServiceReferenceHolder.getInstance().setTaskService(null);
+ }
+
+ protected void deactivate(ComponentContext context) {
+ // Close event publisher connections to message broker
+ EventPublisherPool.close(Util.Topics.INSTANCE_NOTIFIER_TOPIC.getTopicName());
+ EventPublisherPool.close(Util.Topics.TENANT_TOPIC.getTopicName());
+
+ executorService.shutdownNow();
+ //terminate Stratos Manager Topology Receiver
+ topologyEventReceiver.terminate();
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java
deleted file mode 100644
index 10f249c..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/DefaultLoadBalancerCategory.java
+++ /dev/null
@@ -1,117 +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.manager.lb.category;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.ClusterContext;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.client.AutoscalerServiceClient;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-
-import java.rmi.RemoteException;
-import java.util.Map;
-
-public class DefaultLoadBalancerCategory extends LoadBalancerCategory {
-
- private boolean defaultLBExists;
-
- private static Log log = LogFactory.getLog(DefaultLoadBalancerCategory.class);
-
- public PayloadData create(String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries)
- throws ADCException, AlreadySubscribedException {
-
- // call the relevant method to get the cluster id, using deployment policy
- String clusterId = null;
-// try {
-// clusterId = AutoscalerServiceClient.getServiceClient().getDefaultLBClusterId(getDeploymentPolicyName());
-// } catch (Exception e) {
-// log.error("Error occurred in retrieving default LB cluster id" + e.getMessage());
-// throw new ADCException(e);
-// }
-
- if (clusterId != null) {
- //set the cluster id to Cluster object
- cluster.setClusterDomain(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("Set existing default LB cluster id " + clusterId);
- }
- defaultLBExists = true;
-
- //get the hostname for this cluster and set it
- ClusterContext clusterContext;
- try {
- clusterContext = CloudControllerServiceClient.getServiceClient().getClusterContext(clusterId);
-
- } catch (RemoteException e) {
- log.error("Error occurred in retrieving Cluster Context for default LB ", e);
- throw new ADCException(e);
- }
-
- if (clusterContext != null) {
- cluster.setHostName(clusterContext.getHostName());
- if (log.isDebugEnabled()) {
- log.debug("Set existing default LB hostname " + clusterContext.getHostName());
- }
- }
-
- return null;
-
- } else {
- // set cluster domain
- cluster.setClusterDomain(generateClusterId(alias, cartridgeInfo.getType()));
- // set hostname
- cluster.setHostName(generateHostName(alias, cartridgeInfo.getHostName()));
-
- return createPayload(cartridgeInfo, subscriptionKey, subscriber, cluster, repository, alias, customPayloadEntries);
- }
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException {
- log.info("Register service with payload data ["+payloadData+"] ");
- if (!isDefaultLBExists()) {
- if(payloadData != null) {
- log.info("Payload: " + payloadData.getCompletePayloadData().toString());
- }
- super.register(cartridgeInfo, cluster, payloadData, autoscalePolicyName, deploymentPolicyName, properties, persistence);
- }else {
- log.info("Default LB already exists for deployment policy: " + getDeploymentPolicyName());
- }
- }
-
-
- public boolean isDefaultLBExists() {
- return defaultLBExists;
- }
-
- public void setDefaultLBExists(boolean defaultLBExists) {
- this.defaultLBExists = defaultLBExists;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ExistingLoadBalancerCategory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ExistingLoadBalancerCategory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ExistingLoadBalancerCategory.java
deleted file mode 100644
index a1d31f7..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ExistingLoadBalancerCategory.java
+++ /dev/null
@@ -1,54 +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.manager.lb.category;
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.NotSubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-
-import java.util.Map;
-
-public class ExistingLoadBalancerCategory extends LoadBalancerCategory {
-
- public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries) throws ADCException, AlreadySubscribedException {
-
- // TODO
- return null;
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException {
-
- //TODO
- }
-
- public void remove(String clusterId, String alias) throws ADCException, NotSubscribedException {
-
- //TODO
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LBDataContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LBDataContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LBDataContext.java
deleted file mode 100644
index c1631d0..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LBDataContext.java
+++ /dev/null
@@ -1,108 +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.manager.lb.category;
-
-
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.common.Property;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class LBDataContext {
-
- private String lbCategory;
- private int tenantId;
- private String autoscalePolicy;
- private String deploymentPolicy;
- private List<Property> lbProperperties;
- private List<Property> loadBalancedServiceProperties;
- private CartridgeInfo lbCartridgeInfo;
-
-
- public LBDataContext() {
- lbProperperties = new ArrayList<Property>();
- loadBalancedServiceProperties = new ArrayList<Property>();
- }
-
- public CartridgeInfo getLbCartridgeInfo() {
- return lbCartridgeInfo;
- }
-
- public void setLbCartridgeInfo(CartridgeInfo lbCartridgeInfo) {
- this.lbCartridgeInfo = lbCartridgeInfo;
- }
-
- public String getLbCategory() {
- return lbCategory;
- }
-
- public void setLbCategory(String lbCategory) {
- this.lbCategory = lbCategory;
- }
-
- public int getTenantId() {
- return tenantId;
- }
-
- public void setTenantId(int tenantId) {
- this.tenantId = tenantId;
- }
-
- public String getAutoscalePolicy() {
- return autoscalePolicy;
- }
-
- public void setAutoscalePolicy(String autoscalePolicy) {
- this.autoscalePolicy = autoscalePolicy;
- }
-
- public String getDeploymentPolicy() {
- return deploymentPolicy;
- }
-
- public void setDeploymentPolicy(String deploymentPolicy) {
- this.deploymentPolicy = deploymentPolicy;
- }
-
- public List<Property> getLbProperperties() {
- return lbProperperties;
- }
-
- public void addLbProperperty (Property lbProperperty) {
- this.lbProperperties.add(lbProperperty);
- }
-
- public void addLBProperties(Properties loadBalancedServiceProperties) {
-
- for (Property property : loadBalancedServiceProperties.getProperties()) {
- addLbProperperty(property);
- }
- }
-
- public List<Property> getLoadBalancedServiceProperties() {
- return loadBalancedServiceProperties;
- }
-
- public void addLoadBalancedServiceProperty(Property loadBalancedServiceProperty) {
- this.loadBalancedServiceProperties.add(loadBalancedServiceProperty);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LoadBalancerCategory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LoadBalancerCategory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LoadBalancerCategory.java
deleted file mode 100644
index 69bb2cb..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/LoadBalancerCategory.java
+++ /dev/null
@@ -1,122 +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.manager.lb.category;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.PersistenceManagerException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager;
-import org.apache.stratos.manager.subscriber.Subscriber;
-
-import java.util.Map;
-
-public abstract class LoadBalancerCategory extends CartridgeMgtBehaviour {
-
- private String loadBalancedServiceType;
- private boolean isLoadBalancedServiceMultiTenant;
- private String deploymentPolicyName;
- private static Log log = LogFactory.getLog(LoadBalancerCategory.class);
-
- public String getLoadBalancedServiceType() {
- return loadBalancedServiceType;
- }
-
- public void setLoadBalancedServiceType(String loadBalancedServiceType) {
- this.loadBalancedServiceType = loadBalancedServiceType;
- }
-
- public PayloadData create(String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries)
- throws ADCException, AlreadySubscribedException {
-
- String clusterId;
-
- if (isLoadBalancedServiceMultiTenant) {
- // the load balancer should be already up and running from service
- // cluster deployment
-
- // get the cluster domain and host name from deployed Service
-
- Service deployedLBService;
- try {
- deployedLBService = new DataInsertionAndRetrievalManager()
- .getService(cartridgeInfo.getType());
-
- } catch (PersistenceManagerException e) {
- String errorMsg = "Error in checking if Service is available is PersistenceManager";
- log.error(errorMsg, e);
- throw new ADCException(errorMsg, e);
- }
-
- if (deployedLBService == null) {
- String errorMsg = "There is no deployed Service for type "
- + cartridgeInfo.getType();
- log.error(errorMsg);
- throw new ADCException(errorMsg);
- }
-
- if(log.isDebugEnabled()){
- log.debug(" Setting cluster Domain : " + deployedLBService.getClusterId());
- log.debug(" Setting Host Name : " + deployedLBService.getHostName());
- }
-
- // set the cluster and hostname
- cluster.setClusterDomain(deployedLBService.getClusterId());
- cluster.setHostName(deployedLBService.getHostName());
-
- return null;
- } else {
- // set cluster domain
- cluster.setClusterDomain(generateClusterId(alias, cartridgeInfo.getType()));
- // set hostname
- cluster.setHostName(generateHostName(alias, cartridgeInfo.getHostName()));
-
- return createPayload(cartridgeInfo, subscriptionKey, subscriber,
- cluster, repository, alias, customPayloadEntries);
- }
-
-
- }
-
- public boolean isLoadBalancedServiceMultiTenant() {
- return isLoadBalancedServiceMultiTenant;
- }
-
- public void setLoadBalancedServiceMultiTenant(
- boolean isLoadBalancedServiceMultiTenant) {
- this.isLoadBalancedServiceMultiTenant = isLoadBalancedServiceMultiTenant;
- }
-
- public String getDeploymentPolicyName() {
- return deploymentPolicyName;
- }
-
- public void setDeploymentPolicyName(String deploymentPolicyName) {
- this.deploymentPolicyName = deploymentPolicyName;
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java
deleted file mode 100644
index fae0ede..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/lb/category/ServiceLevelLoadBalancerCategory.java
+++ /dev/null
@@ -1,119 +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.manager.lb.category;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
-import org.apache.stratos.cloud.controller.stub.domain.ClusterContext;
-import org.apache.stratos.cloud.controller.stub.domain.Persistence;
-import org.apache.stratos.common.Properties;
-import org.apache.stratos.manager.client.AutoscalerServiceClient;
-import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.dao.Cluster;
-import org.apache.stratos.manager.exception.ADCException;
-import org.apache.stratos.manager.exception.AlreadySubscribedException;
-import org.apache.stratos.manager.exception.UnregisteredCartridgeException;
-import org.apache.stratos.manager.payload.PayloadData;
-import org.apache.stratos.manager.repository.Repository;
-import org.apache.stratos.manager.subscriber.Subscriber;
-import org.apache.stratos.manager.utils.CartridgeConstants;
-
-import java.rmi.RemoteException;
-import java.util.Map;
-
-public class ServiceLevelLoadBalancerCategory extends LoadBalancerCategory {
-
- private static Log log = LogFactory.getLog(ServiceLevelLoadBalancerCategory.class);
-
- private boolean serviceLbExists;
-
- public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, Repository repository, CartridgeInfo cartridgeInfo,
- String subscriptionKey, Map<String, String> customPayloadEntries) throws ADCException, AlreadySubscribedException {
-
- // call the relevant method to get the cluster id, using deployment policy and type
- String clusterId = null;
-
-// try {
-// clusterId = AutoscalerServiceClient.getServiceClient().getServiceLBClusterId(getLoadBalancedServiceType(), getDeploymentPolicyName());
-//
-// } catch (Exception e) {
-// log.error("Error occurred in retrieving Service LB cluster id" + e.getMessage());
-// throw new ADCException(e);
-// }
-
- if (clusterId != null) {
-
- //set the cluster id to Cluster object
- cluster.setClusterDomain(clusterId);
- if (log.isDebugEnabled()) {
- log.debug("Set existing Service LB cluster id " + clusterId);
- }
- serviceLbExists = true;
-
- //get the hostname for this cluster and set it
- ClusterContext clusterContext;
- try {
- clusterContext = CloudControllerServiceClient.getServiceClient().getClusterContext(clusterId);
-
- } catch (RemoteException e) {
- log.error("Error occurred in retrieving Cluster Context for Service LB ", e);
- throw new ADCException(e);
- }
-
- if (clusterContext != null) {
- cluster.setHostName(clusterContext.getHostName());
- if (log.isDebugEnabled()) {
- log.debug("Set existing Service LB hostname " + clusterContext.getHostName());
- }
- }
-
- return null;
-
- } else {
-
- // set cluster domain
- cluster.setClusterDomain(generateClusterId(alias, cartridgeInfo.getType()));
- // set hostname
- cluster.setHostName(generateHostName(alias, cartridgeInfo.getHostName()));
-
- PayloadData serviceLevelLbPayloadData = createPayload(cartridgeInfo, subscriptionKey, subscriber, cluster,
- repository, alias, customPayloadEntries);
-
- // add payload entry for load balanced service type
- serviceLevelLbPayloadData.add(CartridgeConstants.LOAD_BALANCED_SERVICE_TYPE, getLoadBalancedServiceType());
- return serviceLevelLbPayloadData;
- }
- }
-
- public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException {
-
- if (!serviceLbExists) {
-
- // if(payloadData != null) {
- // log.info("Payload: " + payloadData.getCompletePayloadData().toString());
- // }
-
- super.register(cartridgeInfo, cluster, payloadData, autoscalePolicyName, deploymentPolicyName, properties, persistence);
- }else {
- log.info("Service LB already exists for cartridge type: " + getLoadBalancedServiceType() + ", deployment policy: " + getDeploymentPolicyName());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/StratosManagerInstanceStatusEventReceiver.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/StratosManagerInstanceStatusEventReceiver.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/StratosManagerInstanceStatusEventReceiver.java
deleted file mode 100644
index 00c218d..0000000
--- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/listener/StratosManagerInstanceStatusEventReceiver.java
+++ /dev/null
@@ -1,132 +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.manager.listener;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext;
-import org.apache.stratos.autoscaler.stub.pojo.CartridgeContext;
-import org.apache.stratos.autoscaler.stub.pojo.SubscribableInfoContext;
-import org.apache.stratos.manager.client.AutoscalerServiceClient;
-import org.apache.stratos.manager.publisher.InstanceNotificationPublisher;
-import org.apache.stratos.messaging.event.Event;
-import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent;
-import org.apache.stratos.messaging.listener.instance.status.InstanceStartedEventListener;
-import org.apache.stratos.messaging.message.receiver.instance.status.InstanceStatusEventReceiver;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Stratos manager instance status event receiver.
- */
-public class StratosManagerInstanceStatusEventReceiver extends InstanceStatusEventReceiver {
-
- private static final Log log = LogFactory.getLog(StratosManagerInstanceStatusEventReceiver.class);
-
- public StratosManagerInstanceStatusEventReceiver() {
- addEventListeners();
- }
-
- private void addEventListeners() {
- addEventListener(new InstanceStartedEventListener() {
- @Override
- protected void onEvent(Event event) {
- InstanceStartedEvent instanceStartedEvent = (InstanceStartedEvent) event;
- if (log.isInfoEnabled()) {
- log.info(String.format("Instance started event received: [application-id] %s [cartridge-type] %s " +
- "[member-id] %s", instanceStartedEvent.getApplicationId(),
- instanceStartedEvent.getServiceName(), instanceStartedEvent.getMemberId()));
- }
-
- try {
- String applicationId = instanceStartedEvent.getApplicationId();
- String serviceName = instanceStartedEvent.getServiceName();
- String clusterId = instanceStartedEvent.getClusterId();
-
- if (StringUtils.isBlank(applicationId)) {
- throw new RuntimeException("Application id not found in instance started event: " + instanceStartedEvent);
- }
-
- if (StringUtils.isBlank(serviceName)) {
- throw new RuntimeException("Service name not found in instance started event: " + instanceStartedEvent);
- }
-
- if (StringUtils.isBlank(clusterId)) {
- throw new RuntimeException("Cluster id not found in instance started event: " + instanceStartedEvent);
- }
-
- AutoscalerServiceClient autoscalerServiceClient = AutoscalerServiceClient.getServiceClient();
- ApplicationContext applicationContext = autoscalerServiceClient.getApplication(applicationId);
- if (applicationContext == null) {
- throw new RuntimeException("Application not found: [application-id] " + applicationId);
- }
-
- List<SubscribableInfoContext> subscribableInfoContexts = findCartridgeContext(applicationContext, serviceName);
- if ((subscribableInfoContexts == null) || (subscribableInfoContexts.size() == 0)) {
- throw new RuntimeException(String.format("Subscribable information not found: " +
- "[application-id] %s [cartridge-type] %s", applicationId, serviceName));
- }
-
- InstanceNotificationPublisher publisher = new InstanceNotificationPublisher();
-
- for(SubscribableInfoContext subscribableInfoContext : subscribableInfoContexts) {
- String tenantId = "-1234";
- publisher.publishArtifactUpdatedEvent(clusterId, tenantId, subscribableInfoContext.getRepoUrl(), subscribableInfoContext.getRepoUsername(),
- subscribableInfoContext.getRepoPassword(), false);
-
- if (log.isInfoEnabled()) {
- log.info(String.format("Artifact updated event published: [application-id] %s [cartridge-type] %s " +
- "[member-id] %s [subscription-alias] %s [repo-url] %s",
- instanceStartedEvent.getApplicationId(), instanceStartedEvent.getServiceName(),
- instanceStartedEvent.getMemberId(), subscribableInfoContext.getAlias(),
- subscribableInfoContext.getRepoUrl()));
- }
- }
- } catch (Exception e) {
- String message = "Could not send artifact updated event";
- log.error(message, e);
- }
- }
- });
- }
-
- /**
- * Find subscribable info contexts of cartridge type/service name.
- * @param applicationContext
- * @param serviceName
- * @return
- */
- private List<SubscribableInfoContext> findCartridgeContext(ApplicationContext applicationContext, String serviceName) {
- List<SubscribableInfoContext> subscribableInfoContexts = new ArrayList<SubscribableInfoContext>();
- CartridgeContext[] cartridgeContexts = applicationContext.getComponents().getCartridgeContexts();
- if (cartridgeContexts != null) {
- for (CartridgeContext cartridgeContext : cartridgeContexts) {
- if (cartridgeContext != null) {
- if (cartridgeContext.getType().equals(serviceName)) {
- subscribableInfoContexts.add(cartridgeContext.getSubscribableInfoContext());
- }
- }
- }
- }
- return subscribableInfoContexts;
- }
-}
[02/13] stratos git commit: Refining stratos manager component and
removing unused code
Posted by im...@apache.org.
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
index 6cc8ad9..ed8b166 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV40Utils.java
@@ -20,7 +20,6 @@ package org.apache.stratos.rest.endpoint.api;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy;
@@ -32,36 +31,20 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCar
import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException;
import org.apache.stratos.manager.client.AutoscalerServiceClient;
import org.apache.stratos.manager.client.CloudControllerServiceClient;
-import org.apache.stratos.manager.deploy.service.Service;
-import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager;
-import org.apache.stratos.manager.dto.Cartridge;
-import org.apache.stratos.manager.exception.*;
-import org.apache.stratos.manager.manager.CartridgeSubscriptionManager;
-import org.apache.stratos.manager.repository.RepositoryNotification;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.subscription.DataCartridgeSubscription;
-import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel;
+import org.apache.stratos.manager.domain.Cartridge;
+import org.apache.stratos.manager.artifact.distribution.coordinator.RepositoryNotifier;
import org.apache.stratos.manager.utils.ApplicationManagementUtil;
import org.apache.stratos.manager.utils.CartridgeConstants;
-import org.apache.stratos.messaging.domain.topology.Cluster;
-import org.apache.stratos.messaging.domain.topology.Member;
-import org.apache.stratos.messaging.domain.topology.MemberStatus;
-import org.apache.stratos.messaging.message.receiver.topology.TopologyManager;
import org.apache.stratos.common.beans.StratosApiResponse;
import org.apache.stratos.common.beans.SubscriptionDomainRequest;
import org.apache.stratos.common.beans.autoscaler.partition.ApplicationLevelNetworkPartition;
import org.apache.stratos.common.beans.autoscaler.partition.Partition;
import org.apache.stratos.common.beans.autoscaler.policy.autoscale.AutoscalePolicy;
import org.apache.stratos.common.beans.cartridge.definition.CartridgeDefinitionBean;
-import org.apache.stratos.common.beans.cartridge.definition.ServiceDefinitionBean;
import org.apache.stratos.common.beans.repositoryNotificationInfoBean.Payload;
-import org.apache.stratos.common.beans.subscription.domain.SubscriptionDomainBean;
import org.apache.stratos.rest.endpoint.util.converter.ObjectConverter;
import org.apache.stratos.rest.endpoint.exception.RestAPIException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-
import java.rmi.RemoteException;
import java.util.*;
import java.util.regex.Pattern;
@@ -79,8 +62,6 @@ public class StratosApiV40Utils {
public static final String TENANT_RANGE_ALL = "*";
private static Log log = LogFactory.getLog(StratosApiV40Utils.class);
- private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager();
- private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager();
static StratosApiResponse deployCartridge (CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt,
String userName, String tenantDomain) throws RestAPIException {
@@ -547,296 +528,295 @@ public class StratosApiV40Utils {
return cartridges;
}
- private static boolean isAlreadySubscribed(String cartridgeType,
- int tenantId) {
-
- Collection<CartridgeSubscription> subscriptionList = cartridgeSubsciptionManager.isCartridgeSubscribed(tenantId, cartridgeType);
- if(subscriptionList == null || subscriptionList.isEmpty()){
- return false;
- }else {
- return true;
- }
- }
-
- public static List<ServiceDefinitionBean> getdeployedServiceInformation () throws RestAPIException {
-
- Collection<Service> services = null;
-
- try {
- services = serviceDeploymentManager.getServices();
-
- } catch (ADCException e) {
- String msg = "Unable to get deployed service information. Cause: "+e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- if (services != null && !services.isEmpty()) {
- return ObjectConverter.convertToServiceDefinitionBeans(services);
- }
-
- return null;
- }
-
- public static ServiceDefinitionBean getDeployedServiceInformation (String type) throws RestAPIException {
-
- Service service = null;
+ private static boolean isAlreadySubscribed(String cartridgeType, int tenantId) {
- try {
- service = serviceDeploymentManager.getService(type);
-
- } catch (ADCException e) {
- String msg = "Unable to get deployed service information for [type]: " + type+". Cause: "+e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- if (service != null) {
- return ObjectConverter.convertToServiceDefinitionBean(service);
- }
-
- return new ServiceDefinitionBean();
- }
-
- public static List<Cartridge> getActiveDeployedServiceInformation (ConfigurationContext configurationContext) throws RestAPIException {
-
- Collection<Service> services = null;
-
- try {
- services = serviceDeploymentManager.getServices();
-
- } catch (ADCException e) {
- String msg = "Unable to get deployed service information. Cause: "+e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- List<Cartridge> availableMultitenantCartridges = new ArrayList<Cartridge>();
- int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
- //getting the services for the tenantId
- for(Service service : services) {
- String tenantRange = service.getTenantRange();
- if(tenantRange.equals(TENANT_RANGE_ALL)) {
- //check whether any active instances found for this service in the Topology
-
- Cluster cluster = TopologyManager.getTopology().getService(service.getType()).
- getCluster(service.getClusterId());
- boolean activeMemberFound = false;
- for(Member member : cluster.getMembers()) {
- if(member.isActive()) {
- activeMemberFound = true;
- break;
- }
- }
- if(activeMemberFound) {
- availableMultitenantCartridges.add(getAvailableCartridgeInfo(null, true, configurationContext));
- }
- } else {
- //TODO have to check for the serivces which has correct tenant range
- }
- }
-
- /*if (availableMultitenantCartridges.isEmpty()) {
- String msg = "Cannot find any active deployed service for tenant [id] "+tenantId;
- log.error(msg);
- throw new RestAPIException(msg);
- }*/
-
- return availableMultitenantCartridges;
- }
-
- static List<Cartridge> getSubscriptions (String cartridgeSearchString, String serviceGroup, ConfigurationContext configurationContext) throws RestAPIException {
-
- List<Cartridge> cartridges = new ArrayList<Cartridge>();
-
- if (log.isDebugEnabled()) {
- log.debug("Getting subscribed cartridges. Search String: " + cartridgeSearchString);
- }
-
- try {
- Pattern searchPattern = getSearchStringPattern(cartridgeSearchString);
-
- Collection<CartridgeSubscription> subscriptions = cartridgeSubsciptionManager.getCartridgeSubscriptions(ApplicationManagementUtil.
- getTenantId(configurationContext), null);
-
- if (subscriptions != null && !subscriptions.isEmpty()) {
-
- for (CartridgeSubscription subscription : subscriptions) {
-
- if (!cartridgeMatches(subscription.getCartridgeInfo(), subscription, searchPattern)) {
- continue;
- }
- Cartridge cartridge = getCartridgeFromSubscription(subscription);
- if (cartridge == null) {
- continue;
- }
- Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
- cartridge.getCartridgeAlias());
- String cartridgeStatus = "Inactive";
- int activeMemberCount = 0;
- if (cluster != null) {
- Collection<Member> members = cluster.getMembers();
- for (Member member : members) {
- if (member.isActive()) {
- cartridgeStatus = "Active";
- activeMemberCount++;
- }
- }
- }
- cartridge.setActiveInstances(activeMemberCount);
- cartridge.setStatus(cartridgeStatus);
-
- // Ignoring the LB cartridges since they are not shown to the user.
- if(cartridge.isLoadBalancer())
- continue;
- if(StringUtils.isNotEmpty(serviceGroup) && cartridge.getServiceGroup() != null &&
- !cartridge.getServiceGroup().equals(serviceGroup)){
- continue;
- }
- cartridges.add(cartridge);
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("There are no subscribed cartridges");
- }
- }
- } catch (Exception e) {
- String msg = "Error while getting subscribed cartridges. Cause: "+e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- Collections.sort(cartridges);
-
- if (log.isDebugEnabled()) {
- log.debug("Returning subscribed cartridges " + cartridges.size());
- }
-
- /*if(cartridges.isEmpty()) {
- String msg = "Cannot find any subscribed Cartridge, matching the given string: "+cartridgeSearchString;
- log.error(msg);
- throw new RestAPIException(msg);
- }*/
-
- return cartridges;
- }
-
-
- static Cartridge getSubscription(String cartridgeAlias, ConfigurationContext configurationContext) throws RestAPIException {
-
- Cartridge cartridge = getCartridgeFromSubscription(cartridgeSubsciptionManager.getCartridgeSubscription(ApplicationManagementUtil.
- getTenantId(configurationContext), cartridgeAlias));
-
- if (cartridge == null) {
- String message = "Unregistered [alias]: "+cartridgeAlias+"! Please enter a valid alias.";
- log.error(message);
- throw new RestAPIException(Response.Status.NOT_FOUND, message);
- }
- Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
- cartridge.getCartridgeAlias());
- String cartridgeStatus = "Inactive";
- int activeMemberCount = 0;
-
- // cluster might not be created yet, so need to check
- if (cluster != null) {
- Collection<Member> members = cluster.getMembers();
- if (members != null ) {
- for (Member member : members) {
- if(member.isActive()) {
- cartridgeStatus = "Active";
- activeMemberCount++;
- }
- }
- }
- }
-
- cartridge.setActiveInstances(activeMemberCount);
- cartridge.setStatus(cartridgeStatus);
- return cartridge;
-
- }
-
- static int getActiveInstances(String cartridgeType, String cartridgeAlias, ConfigurationContext configurationContext) throws RestAPIException {
- int noOfActiveInstances = 0;
- Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
- cartridgeAlias);
-
- if(cluster == null) {
- String message = "No Cluster found for cartridge [type] "+cartridgeType+", [alias] "+cartridgeAlias;
- log.error(message);
- throw new RestAPIException(message);
- }
-
- for(Member member : cluster.getMembers()) {
- if(member.getStatus().toString().equals(MemberStatus.Activated)) {
- noOfActiveInstances ++;
- }
- }
- return noOfActiveInstances;
+// Collection<CartridgeSubscription> subscriptionList = cartridgeSubsciptionManager.isCartridgeSubscribed(tenantId, cartridgeType);
+// if(subscriptionList == null || subscriptionList.isEmpty()){
+// return false;
+// }else {
+// return true;
+// }
+ return false;
}
- private static Cartridge getCartridgeFromSubscription(CartridgeSubscription subscription) throws RestAPIException {
-
- if (subscription == null) {
- return null;
- }
- try {
- Cartridge cartridge = new Cartridge();
- cartridge.setCartridgeType(subscription.getCartridgeInfo()
- .getType());
- cartridge.setMultiTenant(subscription.getCartridgeInfo()
- .getMultiTenant());
- cartridge
- .setProvider(subscription.getCartridgeInfo().getProvider());
- cartridge.setVersion(subscription.getCartridgeInfo().getVersion());
- cartridge.setDescription(subscription.getCartridgeInfo()
- .getDescription());
- cartridge.setDisplayName(subscription.getCartridgeInfo()
- .getDisplayName());
- cartridge.setCartridgeAlias(subscription.getAlias());
- cartridge.setHostName(subscription.getHostName());
- cartridge.setMappedDomain(subscription.getMappedDomain());
- if (subscription.getRepository() != null) {
- cartridge.setRepoURL(subscription.getRepository().getUrl());
- }
+// public static List<ServiceDefinitionBean> getdeployedServiceInformation () throws RestAPIException {
+//
+// Collection<Service> services = null;
+//
+// try {
+// services = serviceDeploymentManager.getServices();
+//
+// } catch (ADCException e) {
+// String msg = "Unable to get deployed service information. Cause: "+e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(msg, e);
+// }
+//
+// if (services != null && !services.isEmpty()) {
+// return ObjectConverter.convertToServiceDefinitionBeans(services);
+// }
+//
+// return null;
+// }
- if (subscription instanceof DataCartridgeSubscription) {
- DataCartridgeSubscription dataCartridgeSubscription = (DataCartridgeSubscription) subscription;
- cartridge.setDbHost(dataCartridgeSubscription.getDBHost());
- cartridge.setDbUserName(dataCartridgeSubscription
- .getDBUsername());
- cartridge
- .setPassword(dataCartridgeSubscription.getDBPassword());
- }
+// public static ServiceDefinitionBean getDeployedServiceInformation (String type) throws RestAPIException {
+//
+// Service service = null;
+//
+// try {
+// service = serviceDeploymentManager.getService(type);
+//
+// } catch (ADCException e) {
+// String msg = "Unable to get deployed service information for [type]: " + type+". Cause: "+e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(msg, e);
+// }
+//
+// if (service != null) {
+// return ObjectConverter.convertToServiceDefinitionBean(service);
+// }
+//
+// return new ServiceDefinitionBean();
+// }
- if (subscription.getLbClusterId() != null
- && !subscription.getLbClusterId().isEmpty()) {
- cartridge.setLbClusterId(subscription.getLbClusterId());
- }
+// public static List<Cartridge> getActiveDeployedServiceInformation (ConfigurationContext configurationContext) throws RestAPIException {
+//
+// Collection<Service> services = null;
+//
+// try {
+// services = serviceDeploymentManager.getServices();
+//
+// } catch (ADCException e) {
+// String msg = "Unable to get deployed service information. Cause: "+e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(msg, e);
+// }
+//
+// List<Cartridge> availableMultitenantCartridges = new ArrayList<Cartridge>();
+// int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
+// //getting the services for the tenantId
+// for(Service service : services) {
+// String tenantRange = service.getTenantRange();
+// if(tenantRange.equals(TENANT_RANGE_ALL)) {
+// //check whether any active instances found for this service in the Topology
+//
+// Cluster cluster = TopologyManager.getTopology().getService(service.getType()).
+// getCluster(service.getClusterId());
+// boolean activeMemberFound = false;
+// for(Member member : cluster.getMembers()) {
+// if(member.isActive()) {
+// activeMemberFound = true;
+// break;
+// }
+// }
+// if(activeMemberFound) {
+// availableMultitenantCartridges.add(getAvailableCartridgeInfo(null, true, configurationContext));
+// }
+// } else {
+// //TODO have to check for the serivces which has correct tenant range
+// }
+// }
+//
+// /*if (availableMultitenantCartridges.isEmpty()) {
+// String msg = "Cannot find any active deployed service for tenant [id] "+tenantId;
+// log.error(msg);
+// throw new RestAPIException(msg);
+// }*/
+//
+// return availableMultitenantCartridges;
+// }
- cartridge.setStatus(subscription.getSubscriptionStatus());
- cartridge.setPortMappings(subscription.getCartridgeInfo()
- .getPortMappings());
+// static List<Cartridge> getSubscriptions (String cartridgeSearchString, String serviceGroup, ConfigurationContext configurationContext) throws RestAPIException {
+//
+// List<Cartridge> cartridges = new ArrayList<Cartridge>();
+//
+// if (log.isDebugEnabled()) {
+// log.debug("Getting subscribed cartridges. Search String: " + cartridgeSearchString);
+// }
+//
+// try {
+// Pattern searchPattern = getSearchStringPattern(cartridgeSearchString);
+//
+// Collection<CartridgeSubscription> subscriptions = cartridgeSubsciptionManager.getCartridgeSubscriptions(ApplicationManagementUtil.
+// getTenantId(configurationContext), null);
+//
+// if (subscriptions != null && !subscriptions.isEmpty()) {
+//
+// for (CartridgeSubscription subscription : subscriptions) {
+//
+// if (!cartridgeMatches(subscription.getCartridgeInfo(), subscription, searchPattern)) {
+// continue;
+// }
+// Cartridge cartridge = getCartridgeFromSubscription(subscription);
+// if (cartridge == null) {
+// continue;
+// }
+// Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
+// cartridge.getCartridgeAlias());
+// String cartridgeStatus = "Inactive";
+// int activeMemberCount = 0;
+// if (cluster != null) {
+// Collection<Member> members = cluster.getMembers();
+// for (Member member : members) {
+// if (member.isActive()) {
+// cartridgeStatus = "Active";
+// activeMemberCount++;
+// }
+// }
+// }
+// cartridge.setActiveInstances(activeMemberCount);
+// cartridge.setStatus(cartridgeStatus);
+//
+// // Ignoring the LB cartridges since they are not shown to the user.
+// if(cartridge.isLoadBalancer())
+// continue;
+// if(StringUtils.isNotEmpty(serviceGroup) && cartridge.getServiceGroup() != null &&
+// !cartridge.getServiceGroup().equals(serviceGroup)){
+// continue;
+// }
+// cartridges.add(cartridge);
+// }
+// } else {
+// if (log.isDebugEnabled()) {
+// log.debug("There are no subscribed cartridges");
+// }
+// }
+// } catch (Exception e) {
+// String msg = "Error while getting subscribed cartridges. Cause: "+e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(msg, e);
+// }
+//
+// Collections.sort(cartridges);
+//
+// if (log.isDebugEnabled()) {
+// log.debug("Returning subscribed cartridges " + cartridges.size());
+// }
+//
+// /*if(cartridges.isEmpty()) {
+// String msg = "Cannot find any subscribed Cartridge, matching the given string: "+cartridgeSearchString;
+// log.error(msg);
+// throw new RestAPIException(msg);
+// }*/
+//
+// return cartridges;
+// }
- if(subscription.getCartridgeInfo().getLbConfig() != null && subscription.getCartridgeInfo().getProperties() != null) {
- for(org.apache.stratos.cloud.controller.stub.Property property: subscription.getCartridgeInfo().getProperties()) {
- if(property.getName().equals("load.balancer")) {
- cartridge.setLoadBalancer(true);
- }
- }
- }
- if(subscription.getCartridgeInfo().getServiceGroup() != null) {
- cartridge.setServiceGroup(subscription.getCartridgeInfo().getServiceGroup());
- }
- return cartridge;
+// static Cartridge getSubscription(String cartridgeAlias, ConfigurationContext configurationContext) throws RestAPIException {
+//
+// Cartridge cartridge = getCartridgeFromSubscription(cartridgeSubsciptionManager.getCartridgeSubscription(ApplicationManagementUtil.
+// getTenantId(configurationContext), cartridgeAlias));
+//
+// if (cartridge == null) {
+// String message = "Unregistered [alias]: "+cartridgeAlias+"! Please enter a valid alias.";
+// log.error(message);
+// throw new RestAPIException(Response.Status.NOT_FOUND, message);
+// }
+// Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
+// cartridge.getCartridgeAlias());
+// String cartridgeStatus = "Inactive";
+// int activeMemberCount = 0;
+//
+// // cluster might not be created yet, so need to check
+// if (cluster != null) {
+// Collection<Member> members = cluster.getMembers();
+// if (members != null ) {
+// for (Member member : members) {
+// if(member.isActive()) {
+// cartridgeStatus = "Active";
+// activeMemberCount++;
+// }
+// }
+// }
+// }
+//
+// cartridge.setActiveInstances(activeMemberCount);
+// cartridge.setStatus(cartridgeStatus);
+// return cartridge;
+//
+// }
- } catch (Exception e) {
- String msg = "Unable to extract the Cartridge from subscription. Cause: "+e.getMessage();
- log.error(msg);
- throw new RestAPIException(msg);
- }
+// static int getActiveInstances(String cartridgeType, String cartridgeAlias, ConfigurationContext configurationContext) throws RestAPIException {
+// int noOfActiveInstances = 0;
+// Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
+// cartridgeAlias);
+//
+// if(cluster == null) {
+// String message = "No Cluster found for cartridge [type] "+cartridgeType+", [alias] "+cartridgeAlias;
+// log.error(message);
+// throw new RestAPIException(message);
+// }
+//
+// for(Member member : cluster.getMembers()) {
+// if(member.getStatus().toString().equals(MemberStatus.Activated)) {
+// noOfActiveInstances ++;
+// }
+// }
+// return noOfActiveInstances;
+// }
- }
+// private static Cartridge getCartridgeFromSubscription(CartridgeSubscription subscription) throws RestAPIException {
+//
+// if (subscription == null) {
+// return null;
+// }
+// try {
+// Cartridge cartridge = new Cartridge();
+// cartridge.setCartridgeType(subscription.getCartridgeInfo()
+// .getType());
+// cartridge.setMultiTenant(subscription.getCartridgeInfo()
+// .getMultiTenant());
+// cartridge
+// .setProvider(subscription.getCartridgeInfo().getProvider());
+// cartridge.setVersion(subscription.getCartridgeInfo().getVersion());
+// cartridge.setDescription(subscription.getCartridgeInfo()
+// .getDescription());
+// cartridge.setDisplayName(subscription.getCartridgeInfo()
+// .getDisplayName());
+// cartridge.setCartridgeAlias(subscription.getAlias());
+// cartridge.setHostName(subscription.getHostName());
+// cartridge.setMappedDomain(subscription.getMappedDomain());
+// if (subscription.getRepository() != null) {
+// cartridge.setRepoURL(subscription.getRepository().getUrl());
+// }
+//
+// if (subscription instanceof DataCartridgeSubscription) {
+// DataCartridgeSubscription dataCartridgeSubscription = (DataCartridgeSubscription) subscription;
+// cartridge.setDbHost(dataCartridgeSubscription.getDBHost());
+// cartridge.setDbUserName(dataCartridgeSubscription
+// .getDBUsername());
+// cartridge
+// .setPassword(dataCartridgeSubscription.getDBPassword());
+// }
+//
+// if (subscription.getLbClusterId() != null
+// && !subscription.getLbClusterId().isEmpty()) {
+// cartridge.setLbClusterId(subscription.getLbClusterId());
+// }
+//
+// cartridge.setStatus(subscription.getSubscriptionStatus());
+// cartridge.setPortMappings(subscription.getCartridgeInfo()
+// .getPortMappings());
+//
+// if(subscription.getCartridgeInfo().getLbConfig() != null && subscription.getCartridgeInfo().getProperties() != null) {
+// for(org.apache.stratos.cloud.controller.stub.Property property: subscription.getCartridgeInfo().getProperties()) {
+// if(property.getName().equals("load.balancer")) {
+// cartridge.setLoadBalancer(true);
+// }
+// }
+// }
+// if(subscription.getCartridgeInfo().getServiceGroup() != null) {
+// cartridge.setServiceGroup(subscription.getCartridgeInfo().getServiceGroup());
+// }
+// return cartridge;
+//
+// } catch (Exception e) {
+// String msg = "Unable to extract the Cartridge from subscription. Cause: "+e.getMessage();
+// log.error(msg);
+// throw new RestAPIException(msg);
+// }
+//
+// }
static Pattern getSearchStringPattern(String searchString) {
if (log.isDebugEnabled()) {
@@ -870,89 +850,89 @@ public class StratosApiV40Utils {
return true;
}
- static boolean cartridgeMatches(CartridgeInfo cartridgeInfo, CartridgeSubscription cartridgeSubscription, Pattern pattern) {
- if (pattern != null) {
- boolean matches = false;
- if (cartridgeInfo.getDisplayName() != null) {
- matches = pattern.matcher(cartridgeInfo.getDisplayName().toLowerCase()).find();
- }
- if (!matches && cartridgeInfo.getDescription() != null) {
- matches = pattern.matcher(cartridgeInfo.getDescription().toLowerCase()).find();
- }
- if (!matches && cartridgeSubscription.getType() != null) {
- matches = pattern.matcher(cartridgeSubscription.getType().toLowerCase()).find();
- }
- if (!matches && cartridgeSubscription.getAlias() != null) {
- matches = pattern.matcher(cartridgeSubscription.getAlias().toLowerCase()).find();
- }
- return matches;
- }
- return true;
- }
-
- public static CartridgeSubscription getCartridgeSubscription(String alias, ConfigurationContext configurationContext) {
- return cartridgeSubsciptionManager.getCartridgeSubscription(ApplicationManagementUtil.getTenantId(configurationContext), alias);
- }
-
- public static org.apache.stratos.common.beans.topology.Cluster getCluster (String cartridgeType, String subscriptionAlias, ConfigurationContext configurationContext) throws RestAPIException {
-
- Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
- subscriptionAlias);
- if(cluster == null) {
- throw new RestAPIException("No matching cluster found for [cartridge type]: "+cartridgeType+ " [alias] "+subscriptionAlias);
- } else{
- return ObjectConverter.convertClusterToClusterBean(cluster, null);
- }
- }
-
- public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenant (ConfigurationContext configurationContext) {
-
- Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
- getTenantId(configurationContext), null);
- ArrayList<org.apache.stratos.common.beans.topology.Cluster> clusters =
- new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
- for(Cluster cluster : clusterSet) {
- clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
- }
- org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
- new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
- arrCluster = clusters.toArray(arrCluster);
- return arrCluster;
-
- }
-
- public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenantAndCartridgeType (ConfigurationContext configurationContext,
- String cartridgeType) {
-
- Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
- getTenantId(configurationContext), cartridgeType);
- List<org.apache.stratos.common.beans.topology.Cluster> clusters =
- new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
- for(Cluster cluster : clusterSet) {
- clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
- }
- org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
- new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
- arrCluster = clusters.toArray(arrCluster);
- return arrCluster;
+// static boolean cartridgeMatches(CartridgeInfo cartridgeInfo, CartridgeSubscription cartridgeSubscription, Pattern pattern) {
+// if (pattern != null) {
+// boolean matches = false;
+// if (cartridgeInfo.getDisplayName() != null) {
+// matches = pattern.matcher(cartridgeInfo.getDisplayName().toLowerCase()).find();
+// }
+// if (!matches && cartridgeInfo.getDescription() != null) {
+// matches = pattern.matcher(cartridgeInfo.getDescription().toLowerCase()).find();
+// }
+// if (!matches && cartridgeSubscription.getType() != null) {
+// matches = pattern.matcher(cartridgeSubscription.getType().toLowerCase()).find();
+// }
+// if (!matches && cartridgeSubscription.getAlias() != null) {
+// matches = pattern.matcher(cartridgeSubscription.getAlias().toLowerCase()).find();
+// }
+// return matches;
+// }
+// return true;
+// }
- }
+// public static CartridgeSubscription getCartridgeSubscription(String alias, ConfigurationContext configurationContext) {
+// return cartridgeSubsciptionManager.getCartridgeSubscription(ApplicationManagementUtil.getTenantId(configurationContext), alias);
+// }
+//
+// public static org.apache.stratos.common.beans.topology.Cluster getCluster (String cartridgeType, String subscriptionAlias, ConfigurationContext configurationContext) throws RestAPIException {
+//
+// Cluster cluster = TopologyClusterInformationModel.getInstance().getCluster(ApplicationManagementUtil.getTenantId(configurationContext),
+// subscriptionAlias);
+// if(cluster == null) {
+// throw new RestAPIException("No matching cluster found for [cartridge type]: "+cartridgeType+ " [alias] "+subscriptionAlias);
+// } else{
+// return ObjectConverter.convertClusterToClusterBean(cluster, null);
+// }
+// }
- public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForCartridgeType(String cartridgeType) {
+// public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenant (ConfigurationContext configurationContext) {
+//
+// Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
+// getTenantId(configurationContext), null);
+// ArrayList<org.apache.stratos.common.beans.topology.Cluster> clusters =
+// new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
+// for(Cluster cluster : clusterSet) {
+// clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
+// }
+// org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
+// new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
+// arrCluster = clusters.toArray(arrCluster);
+// return arrCluster;
+//
+// }
- Set<Cluster> clusterSet = TopologyClusterInformationModel
- .getInstance()
- .getClusters(cartridgeType);
- List<org.apache.stratos.common.beans.topology.Cluster> clusters = new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
- for (Cluster cluster : clusterSet) {
- clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
- }
- org.apache.stratos.common.beans.topology.Cluster[] arrCluster = new org.apache.stratos.common.beans.topology.Cluster[clusters
- .size()];
- arrCluster = clusters.toArray(arrCluster);
- return arrCluster;
+// public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForTenantAndCartridgeType (ConfigurationContext configurationContext,
+// String cartridgeType) {
+//
+// Set<Cluster> clusterSet = TopologyClusterInformationModel.getInstance().getClusters(ApplicationManagementUtil.
+// getTenantId(configurationContext), cartridgeType);
+// List<org.apache.stratos.common.beans.topology.Cluster> clusters =
+// new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
+// for(Cluster cluster : clusterSet) {
+// clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
+// }
+// org.apache.stratos.common.beans.topology.Cluster[] arrCluster =
+// new org.apache.stratos.common.beans.topology.Cluster[clusters.size()];
+// arrCluster = clusters.toArray(arrCluster);
+// return arrCluster;
+//
+// }
- }
+// public static org.apache.stratos.common.beans.topology.Cluster[] getClustersForCartridgeType(String cartridgeType) {
+//
+// Set<Cluster> clusterSet = TopologyClusterInformationModel
+// .getInstance()
+// .getClusters(cartridgeType);
+// List<org.apache.stratos.common.beans.topology.Cluster> clusters = new ArrayList<org.apache.stratos.common.beans.topology.Cluster>();
+// for (Cluster cluster : clusterSet) {
+// clusters.add(ObjectConverter.convertClusterToClusterBean(cluster, null));
+// }
+// org.apache.stratos.common.beans.topology.Cluster[] arrCluster = new org.apache.stratos.common.beans.topology.Cluster[clusters
+// .size()];
+// arrCluster = clusters.toArray(arrCluster);
+// return arrCluster;
+//
+// }
// return the cluster id for the lb. This is a temp fix.
/*private static String subscribeToLb(String cartridgeType, String loadBalancedCartridgeType, String lbAlias,
@@ -995,71 +975,28 @@ public class StratosApiV40Utils {
static StratosApiResponse unsubscribe(String alias, String tenantDomain) throws RestAPIException {
- try {
- cartridgeSubsciptionManager.unsubscribeFromCartridge(tenantDomain, alias);
-
- } catch (ADCException e) {
- String msg = "Failed to unsubscribe from [alias] "+alias+". Cause: "+ e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
-
- } catch (NotSubscribedException e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
- }
-
- StratosApiResponse stratosApiResponse = new StratosApiResponse();
- stratosApiResponse.setMessage("Successfully terminated the subscription with alias " + alias);
- return stratosApiResponse;
- }
-
- /**
- *
- * Super tenant will deploy multitenant service.
- *
- * get domain , subdomain as well..
- * @param clusterDomain
- * @param clusterSubdomain
- *
- */
- static StratosApiResponse deployService(String cartridgeType, String alias, String autoscalingPolicy, String deploymentPolicy,
- String tenantDomain, String tenantUsername, int tenantId, String clusterDomain, String clusterSubdomain, String tenantRange) throws RestAPIException {
- log.info("Deploying service..");
- try {
- serviceDeploymentManager.deployService(cartridgeType, autoscalingPolicy, deploymentPolicy,
- tenantId, tenantRange, tenantDomain, tenantUsername, false);
-
- } catch (Exception e) {
- String msg = String.format("Failed to deploy the Service [Cartridge type] %s [alias] %s . Cause: %s", cartridgeType, alias, e.getMessage());
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- StratosApiResponse stratosApiResponse = new StratosApiResponse();
- stratosApiResponse.setMessage("Successfully deployed service cluster definition with type " + cartridgeType);
- return stratosApiResponse;
- }
-
- static StratosApiResponse undeployService(String serviceType) throws RestAPIException {
-
- try {
- serviceDeploymentManager.undeployService(serviceType);
-
- } catch (Exception e) {
- String msg = "Failed to undeploy service cluster definition of type " + serviceType+" Cause: "+e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- StratosApiResponse stratosApiResponse = new StratosApiResponse();
- stratosApiResponse.setMessage("Successfully undeployed service cluster definition for service type " + serviceType);
- return stratosApiResponse;
+ throw new RestAPIException("Not implemented");
+// try {
+// cartridgeSubsciptionManager.unsubscribeFromCartridge(tenantDomain, alias);
+// } catch (ADCException e) {
+// String msg = "Failed to unsubscribe from [alias] "+alias+". Cause: "+ e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(msg, e);
+//
+// } catch (NotSubscribedException e) {
+// log.error(e.getMessage(), e);
+// throw new RestAPIException(e.getMessage(), e);
+// }
+//
+// StratosApiResponse stratosApiResponse = new StratosApiResponse();
+// stratosApiResponse.setMessage("Successfully terminated the subscription with alias " + alias);
+// return stratosApiResponse;
}
static void getGitRepositoryNotification(Payload payload) throws RestAPIException {
try {
- RepositoryNotification repoNotification = new RepositoryNotification();
+ RepositoryNotifier repoNotification = new RepositoryNotifier();
repoNotification.updateRepository(payload.getRepository().getUrl());
} catch (Exception e) {
@@ -1069,115 +1006,118 @@ public class StratosApiV40Utils {
}
}
- static StratosApiResponse synchronizeRepository(CartridgeSubscription cartridgeSubscription) throws RestAPIException {
- try {
- RepositoryNotification repoNotification = new RepositoryNotification();
- repoNotification.updateRepository(cartridgeSubscription);
- } catch (Exception e) {
- String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
- log.error(msg, e);
- throw new RestAPIException(msg, e);
- }
-
- StratosApiResponse stratosApiResponse = new StratosApiResponse();
- stratosApiResponse.setMessage("Successfully sent the repository synchronization request for " + cartridgeSubscription.getAlias());
- return stratosApiResponse;
- }
+// static StratosApiResponse synchronizeRepository(CartridgeSubscription cartridgeSubscription) throws RestAPIException {
+// try {
+// RepositoryNotifier repoNotification = new RepositoryNotifier();
+// repoNotification.updateRepository(cartridgeSubscription);
+// } catch (Exception e) {
+// String msg = "Failed to get git repository notifications. Cause : " + e.getMessage();
+// log.error(msg, e);
+// throw new RestAPIException(msg, e);
+// }
+//
+// StratosApiResponse stratosApiResponse = new StratosApiResponse();
+// stratosApiResponse.setMessage("Successfully sent the repository synchronization request for " + cartridgeSubscription.getAlias());
+// return stratosApiResponse;
+// }
public static StratosApiResponse addSubscriptionDomains(ConfigurationContext configurationContext, String cartridgeType,
String subscriptionAlias,
SubscriptionDomainRequest request)
throws RestAPIException {
- try {
- int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
-
- for (org.apache.stratos.common.beans.subscription.domain.SubscriptionDomainBean subscriptionDomain : request.getDomains()) {
- boolean isDomainExists = isSubscriptionDomainExists(configurationContext, cartridgeType, subscriptionAlias, subscriptionDomain.getDomainName());
- if (isDomainExists) {
- String message = "Subscription domain " + subscriptionDomain.getDomainName() + " exists";
- throw new RestAPIException(Status.INTERNAL_SERVER_ERROR, message);
- }
- }
-
- for (org.apache.stratos.common.beans.subscription.domain.SubscriptionDomainBean subscriptionDomain : request.getDomains()) {
- cartridgeSubsciptionManager.addSubscriptionDomain(tenantId, subscriptionAlias,
- subscriptionDomain.getDomainName(), subscriptionDomain.getApplicationContext());
- }
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
- }
-
- StratosApiResponse stratosApiResponse = new StratosApiResponse();
- stratosApiResponse.setMessage("Successfully added domains to cartridge subscription");
- return stratosApiResponse;
- }
-
- public static boolean isSubscriptionDomainExists(ConfigurationContext configurationContext, String cartridgeType,
- String subscriptionAlias, String domain) throws RestAPIException {
- try {
- int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
- SubscriptionDomainBean subscriptionDomain = ObjectConverter.populateSubscriptionDomainPojo(cartridgeSubsciptionManager.getSubscriptionDomain(tenantId,
- subscriptionAlias, domain));
-
- if (subscriptionDomain.getDomainName() != null) {
- return true;
- } else {
- return false;
- }
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
- }
+// try {
+// int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
+//
+// for (org.apache.stratos.common.beans.subscription.domain.SubscriptionDomainBean subscriptionDomain : request.getDomains()) {
+// boolean isDomainExists = isSubscriptionDomainExists(configurationContext, cartridgeType, subscriptionAlias, subscriptionDomain.getDomainName());
+// if (isDomainExists) {
+// String message = "Subscription domain " + subscriptionDomain.getDomainName() + " exists";
+// throw new RestAPIException(Status.INTERNAL_SERVER_ERROR, message);
+// }
+// }
+//
+// for (org.apache.stratos.common.beans.subscription.domain.SubscriptionDomainBean subscriptionDomain : request.getDomains()) {
+// cartridgeSubsciptionManager.addSubscriptionDomain(tenantId, subscriptionAlias,
+// subscriptionDomain.getDomainName(), subscriptionDomain.getApplicationContext());
+// }
+// } catch (Exception e) {
+// log.error(e.getMessage(), e);
+// throw new RestAPIException(e.getMessage(), e);
+// }
- }
+// StratosApiResponse stratosApiResponse = new StratosApiResponse();
+// stratosApiResponse.setMessage("Successfully added domains to cartridge subscription");
+// return stratosApiResponse;
- public static List<SubscriptionDomainBean> getSubscriptionDomains(ConfigurationContext configurationContext, String cartridgeType,
- String subscriptionAlias) throws RestAPIException {
- try {
- int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
- return ObjectConverter.populateSubscriptionDomainPojos(cartridgeSubsciptionManager.getSubscriptionDomains(tenantId, subscriptionAlias));
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
- }
+ throw new RestAPIException("Not implemented");
}
- public static SubscriptionDomainBean getSubscriptionDomain(ConfigurationContext configurationContext, String cartridgeType,
- String subscriptionAlias, String domain) throws RestAPIException {
- try {
- int tenantId = ApplicationManagementUtil
- .getTenantId(configurationContext);
- SubscriptionDomainBean subscriptionDomain = ObjectConverter.populateSubscriptionDomainPojo(cartridgeSubsciptionManager.getSubscriptionDomain(tenantId,
- subscriptionAlias, domain));
-
- if (subscriptionDomain == null) {
- String message = "Could not find a subscription [domain] "+domain+ " for Cartridge [type] "
- +cartridgeType+ " and [alias] "+subscriptionAlias;
- log.error(message);
- throw new RestAPIException(Status.NOT_FOUND, message);
- }
-
- return subscriptionDomain;
-
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
- }
- }
+// public static boolean isSubscriptionDomainExists(ConfigurationContext configurationContext, String cartridgeType,
+// String subscriptionAlias, String domain) throws RestAPIException {
+// try {
+// int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
+// SubscriptionDomainBean subscriptionDomain = ObjectConverter.populateSubscriptionDomainPojo(cartridgeSubsciptionManager.getSubscriptionDomain(tenantId,
+// subscriptionAlias, domain));
+//
+// if (subscriptionDomain.getDomainName() != null) {
+// return true;
+// } else {
+// return false;
+// }
+// } catch (Exception e) {
+// log.error(e.getMessage(), e);
+// throw new RestAPIException(e.getMessage(), e);
+// }
+//
+// }
+
+// public static List<SubscriptionDomainBean> getSubscriptionDomains(ConfigurationContext configurationContext, String cartridgeType,
+// String subscriptionAlias) throws RestAPIException {
+// try {
+// int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
+// return ObjectConverter.populateSubscriptionDomainPojos(cartridgeSubsciptionManager.getSubscriptionDomains(tenantId, subscriptionAlias));
+// } catch (Exception e) {
+// log.error(e.getMessage(), e);
+// throw new RestAPIException(e.getMessage(), e);
+// }
+// }
+
+// public static SubscriptionDomainBean getSubscriptionDomain(ConfigurationContext configurationContext, String cartridgeType,
+// String subscriptionAlias, String domain) throws RestAPIException {
+// try {
+// int tenantId = ApplicationManagementUtil
+// .getTenantId(configurationContext);
+// SubscriptionDomainBean subscriptionDomain = ObjectConverter.populateSubscriptionDomainPojo(cartridgeSubsciptionManager.getSubscriptionDomain(tenantId,
+// subscriptionAlias, domain));
+//
+// if (subscriptionDomain == null) {
+// String message = "Could not find a subscription [domain] "+domain+ " for Cartridge [type] "
+// +cartridgeType+ " and [alias] "+subscriptionAlias;
+// log.error(message);
+// throw new RestAPIException(Status.NOT_FOUND, message);
+// }
+//
+// return subscriptionDomain;
+//
+// } catch (Exception e) {
+// log.error(e.getMessage(), e);
+// throw new RestAPIException(e.getMessage(), e);
+// }
+// }
public static StratosApiResponse removeSubscriptionDomain(ConfigurationContext configurationContext, String cartridgeType,
String subscriptionAlias, String domain) throws RestAPIException {
- try {
- int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
- cartridgeSubsciptionManager.removeSubscriptionDomain(tenantId, subscriptionAlias, domain);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- throw new RestAPIException(e.getMessage(), e);
- }
-
- StratosApiResponse stratosApiResponse = new StratosApiResponse();
- stratosApiResponse.setMessage("Successfully removed domains from cartridge subscription");
- return stratosApiResponse;
+// try {
+// int tenantId = ApplicationManagementUtil.getTenantId(configurationContext);
+// cartridgeSubsciptionManager.removeSubscriptionDomain(tenantId, subscriptionAlias, domain);
+// } catch (Exception e) {
+// log.error(e.getMessage(), e);
+// throw new RestAPIException(e.getMessage(), e);
+// }
+//
+// StratosApiResponse stratosApiResponse = new StratosApiResponse();
+// stratosApiResponse.setMessage("Successfully removed domains from cartridge subscription");
+// return stratosApiResponse;
+ throw new RestAPIException("Not implemented");
}
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/79c69e77/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index 1078b45..0bcc9ea 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -33,13 +33,11 @@ import org.apache.stratos.common.beans.topology.ApplicationInfoBean;
import org.apache.stratos.common.beans.topology.Cluster;
import org.apache.stratos.common.util.ClaimsMgtUtil;
import org.apache.stratos.common.util.CommonUtil;
-import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition;
-import org.apache.stratos.manager.dto.Cartridge;
-import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition;
-import org.apache.stratos.manager.subscription.ApplicationSubscription;
-import org.apache.stratos.manager.subscription.CartridgeSubscription;
-import org.apache.stratos.manager.user.mgt.StratosUserManager;
-import org.apache.stratos.manager.user.mgt.exception.UserManagerException;
+import org.apache.stratos.manager.domain.ApplicationDefinition;
+import org.apache.stratos.manager.domain.ApplicationSubscription;
+import org.apache.stratos.manager.domain.ServiceGroupDefinition;
+import org.apache.stratos.manager.user.management.StratosUserManager;
+import org.apache.stratos.manager.user.management.exception.UserManagerException;
import org.apache.stratos.rest.endpoint.ServiceHolder;
import org.apache.stratos.rest.endpoint.Utils;
import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction;
@@ -143,8 +141,7 @@ public class StratosApiV41 extends AbstractApi {
@AuthorizationAction("/permission/admin/manage/add/cartridgeDefinition")
public Response addCartridge(CartridgeDefinitionBean cartridgeDefinitionBean)
throws RestAPIException {
- StratosApiV41Utils.addCartridge(cartridgeDefinitionBean, getConfigContext(), getUsername(),
- getTenantDomain());
+ StratosApiV41Utils.addCartridge(cartridgeDefinitionBean);
URI url = uriInfo.getAbsolutePathBuilder().path(cartridgeDefinitionBean.getType()).build();
return Response.created(url).build();
@@ -593,7 +590,7 @@ public class StratosApiV41 extends AbstractApi {
@Consumes("application/json")
@AuthorizationAction("/permission/protected/manage/monitor/tenants")
public Response getSubscriptionsForApplication(@PathParam("applicationId") String applicationId) throws RestAPIException {
- ApplicationSubscription subscriptions = StratosApiV41Utils.getApplicationSubscriptions(applicationId, getConfigContext());
+ List<ApplicationSubscription> subscriptions = StratosApiV41Utils.getApplicationSubscriptions(applicationId);
if (subscriptions == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
@@ -613,11 +610,7 @@ public class StratosApiV41 extends AbstractApi {
@Consumes("application/json")
@AuthorizationAction("/permission/admin/manage/view/cartridge")
public Response getSubscribedCartridgesForServiceGroup(@PathParam("serviceGroupId") String serviceGroup) throws RestAPIException {
- List<Cartridge> cartridgeList = StratosApiV41Utils.getSubscriptions(null, serviceGroup, getConfigContext());
- // Following is very important when working with axis2
- ResponseBuilder rb = Response.ok();
- rb.entity(cartridgeList.isEmpty() ? new Cartridge[0] : cartridgeList.toArray(new Cartridge[cartridgeList.size()]));
- return rb.build();
+ throw new RestAPIException("Not implemented");
}
// API methods for clusters
@@ -628,7 +621,8 @@ public class StratosApiV41 extends AbstractApi {
@Consumes("application/json")
@AuthorizationAction("/permission/admin/manage/view/cluster")
public Response getClustersForTenant() throws RestAPIException {
- return Response.ok().entity(StratosApiV41Utils.getClustersForTenant(getConfigContext())).build();
+// return Response.ok().entity(StratosApiV41Utils.getClustersForTenant(getConfigContext())).build();
+ throw new RestAPIException("Not implemented");
}
@GET
@@ -638,9 +632,10 @@ public class StratosApiV41 extends AbstractApi {
@AuthorizationAction("/permission/admin/manage/view/cluster")
public Response getClustersForCartridge(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException {
- ResponseBuilder rb = Response.ok();
- rb.entity(StratosApiV41Utils.getClustersForTenantAndCartridgeType(getConfigContext(), cartridgeType));
- return rb.build();
+// ResponseBuilder rb = Response.ok();
+// rb.entity(StratosApiV41Utils.getClustersForTenantAndCartridgeType(getConfigContext(), cartridgeType));
+// return rb.build();
+ throw new RestAPIException("Not implemented");
}
@GET
@@ -649,24 +644,25 @@ public class StratosApiV41 extends AbstractApi {
@Consumes("application/json")
@AuthorizationAction("/permission/admin/manage/view/cluster")
public Response getClusterForTenant(@PathParam("clusterId") String clusterId) throws RestAPIException {
- Cluster cluster = null;
- if (log.isDebugEnabled()) {
- log.debug("Finding cluster for [id]: " + clusterId);
- }
- Cluster[] clusters = StratosApiV41Utils.getClustersForTenant(getConfigContext());
- if (log.isDebugEnabled()) {
- log.debug("Clusters retrieved from backend for cluster [id]: " + clusterId);
- for (Cluster c : clusters) {
- log.debug(c + "\n");
- }
- }
- for (Cluster clusterObj : clusters) {
- if (clusterObj.getClusterId().equals(clusterId)) {
- cluster = clusterObj;
- break;
- }
- }
- return Response.ok().entity(cluster).build();
+// Cluster cluster = null;
+// if (log.isDebugEnabled()) {
+// log.debug("Finding cluster for [id]: " + clusterId);
+// }
+// Cluster[] clusters = StratosApiV41Utils.getClustersForTenant(getConfigContext());
+// if (log.isDebugEnabled()) {
+// log.debug("Clusters retrieved from backend for cluster [id]: " + clusterId);
+// for (Cluster c : clusters) {
+// log.debug(c + "\n");
+// }
+// }
+// for (Cluster clusterObj : clusters) {
+// if (clusterObj.getClusterId().equals(clusterId)) {
+// cluster = clusterObj;
+// break;
+// }
+// }
+// return Response.ok().entity(cluster).build();
+ throw new RestAPIException("Not implemented");
}
// API methods for tenants
@@ -1226,13 +1222,10 @@ public class StratosApiV41 extends AbstractApi {
if (log.isDebugEnabled()) {
log.debug(String.format("Synchronizing Git repository for alias '%s'", alias));
}
- CartridgeSubscription cartridgeSubscription = StratosApiV41Utils.getCartridgeSubscription(alias, getConfigContext());
- if (cartridgeSubscription != null && cartridgeSubscription.getRepository() != null && log.isDebugEnabled()) {
- log.debug(String.format("Found subscription for '%s'. Git repository: %s", alias, cartridgeSubscription
- .getRepository().getUrl()));
- }
- StratosApiV41Utils.synchronizeRepository(cartridgeSubscription);
- return Response.noContent().build();
+
+// StratosApiV41Utils.synchronizeRepository(cartridgeSubscription);
+// return Response.noContent().build();
+ throw new RestAPIException("Not implemented");
}
// API methods for users